Quantcast

- Location - add back 'most damaged'; add new option to hide totals; equipment scan rewritten

urnati [01-09-24 - 23:33]
- Location - add back 'most damaged'; add new option to hide totals; equipment scan rewritten
- Update config for release
Filename
Titan/TitanConfig.lua
TitanRepair/TitanRepair.lua
diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua
index b16a101..34afd77 100644
--- a/Titan/TitanConfig.lua
+++ b/Titan/TitanConfig.lua
@@ -60,6 +60,12 @@ changes = changes
 	..TitanUtils_GetHighlightText(""
 		.."- Classic (Wrath and Era) put coords on bottom of small and large maps, if user selected.\n"
 		)
+	..TitanUtils_GetGreenText("Repair All : \n")
+	..TitanUtils_GetHighlightText(""
+		.."- Add back option to show / hide most damaged equipped item.\n"
+		.."- New option to show / hide total % and cost.\n"
+		.."- Scan of equipped items rewritten.\n"
+		)
 	.."\n\n"
 	..TitanUtils_GetGoldText("8.0.0 : 2023/12/23\n")
 	..TitanUtils_GetGreenText("Titan single release version : \n")
diff --git a/TitanRepair/TitanRepair.lua b/TitanRepair/TitanRepair.lua
index 1f0e08d..c229b82 100644
--- a/TitanRepair/TitanRepair.lua
+++ b/TitanRepair/TitanRepair.lua
@@ -19,6 +19,13 @@ local TR = TitanRepair
 TR.ITEM_STATUS = {};
 TR.ITEM_BAG = {};

+local AceTimer = LibStub("AceTimer-3.0")
+local TR_Timer = nil
+local TR_Timer_active = false
+
+local parse_item =
+	"|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?"
+
 -- locals
 TR.repair_total = 0
 TR.dur_total = 0
@@ -29,10 +36,55 @@ TR.repair_equip = {}
 TR.money_total = 0
 TR.bag_list = {}
 TR.equip_list = {}
-TR.equip_most = nil
+TR.equip_most_default = {
+	name = UNKNOWN,
+	quality = UNKNOWN,
+	color = UNKNOWN,
+	dur_max = 0,
+	dur_cur = 0,
+	dur_per = 100,
+	cost = 0,
+	}
+TR.equip_most = {
+	name = UNKNOWN,
+	quality = UNKNOWN,
+	color = UNKNOWN,
+	dur_max = 0,
+	dur_cur = 0,
+	dur_per = 100,
+	cost = 0,
+	}
+
 TR.last_scan = GetTime() -- seconds with milliseconds - sec.milli
 TR.scan_time = 0
 TR.scan_running = false
+if TITAN_ID == "TitanClassic" then
+	TR.scan_start = 18
+else
+	TR.scan_start = 17
+end
+TR.scan_end = 1
+
+local slots = {
+	[1] = {name = "HEADSLOT"},
+	[2] = {name = "NECKSLOT"},
+	[3] = {name = "SHOULDERSLOT"},
+	[4] = {name = "SHIRTSLOT"},
+	[5] = {name = "CHESTSLOT"},
+	[6] = {name = "WAISTSLOT"},
+	[7] = {name = "LEGSSLOT"},
+	[8] = {name = "FEETSLOT"},
+	[9] = {name = "WRISTSLOT"},
+	[10] = {name = "HANDSSLOT"},
+	[11] = {name = "FINGER0SLOT"},
+	[12] = {name = "FINGER1SLOT"},
+	[13] = {name = "TRINKET0SLOT"},
+	[14] = {name = "TRINKET1SLOT"},
+	[15] = {name = "BACKSLOT"},
+	[16] = {name = "MAINHANDSLOT"},
+	[17] = {name = "SECONDARYHANDSLOT"},
+	[18] = {name = "RANGEDSLOT"},
+}

 TR.guild_bank = true
 TR.wowversion  = select(4, GetBuildInfo())
@@ -44,9 +96,11 @@ else
 	TR.guild_bank = true
 end

+
 --debug
 TR.show_debug = false -- will tell you a lot about what's happening
-TR.show_debug_scan = true -- shows items processed during scan
+TR.show_debug_scan = false -- shows items processed during scan
+TR.show_debug_tooltip = false -- shows items processed during scan

 -- ******************************** Functions *******************************

@@ -58,16 +112,14 @@ TR.show_debug_scan = true -- shows items processed during scan
 -- **************************************************************************
 --]]
 local function debug_msg(Message)
-	if (TR.show_debug) then
-		local msg = ""
-		local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S")
-		local milli = GetTime() -- seconds with millisecond precision (float)
-		milli = string.format("%0.2F", milli - math.modf(milli))
-		msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_REPAIR_ID..": ")
-		msg = msg..TitanUtils_GetGreenText(Message)
-		DEFAULT_CHAT_FRAME:AddMessage(msg)
+	local msg = ""
+	local stamp = date("%H:%M:%S") -- date("%m/%d/%y %H:%M:%S")
+	local milli = GetTime() -- seconds with millisecond precision (float)
+	milli = string.format("%0.2F", milli - math.modf(milli))
+	msg = msg..TitanUtils_GetGoldText(stamp..milli.." "..TITAN_REPAIR_ID..": ")
+	msg = msg..TitanUtils_GetGreenText(Message)
+	DEFAULT_CHAT_FRAME:AddMessage(msg)
 --		DEFAULT_CHAT_FRAME:AddMessage(TITAN_REPAIR_ID..": " .. Message, 1.00, 0.49, 0.04)
-	end
 end

 --[[ local
@@ -89,7 +141,17 @@ local function RepairInit()
 	TR.money_total = 0
 	TR.bag_list = {}
 	TR.equip_list = {}
-	TR.equip_most = nil
+	TR.equip_most = {}
+
+	TR.equip_most = {
+		name = TR.equip_most_default.name,
+		quality = TR.equip_most_default.quality,
+		color = TR.equip_most_default.color,
+		dur_max = TR.equip_most_default.dur_max,
+		dur_cur = TR.equip_most_default.dur_cur,
+		dur_per = TR.equip_most_default.dur_per,
+		cost = TR.equip_most_default.cost,
+		}
 end

 --[[ local
@@ -107,6 +169,7 @@ local function GetRepairCostEquip(slotName, slot)
 	local equipped = false
 	local res = 0
 	local name = ""
+
 	--Blizz changed SetInventoryItem for DragonFlight
 	-- use a proxy for retail (true) versus classic (false)
 	if C_TooltipInfo then
@@ -128,7 +191,6 @@ local function GetRepairCostEquip(slotName, slot)

 		-- debug
 		if hasItem then
-			name, _, itemRarity, _,	_, itemType, itemSubType = GetItemInfo(GetInventoryItemLink("player", slot) or "")
 			equipped = true
 		else
 			name = ""
@@ -136,6 +198,7 @@ local function GetRepairCostEquip(slotName, slot)
 		end
 		TitanRepairTooltip:Hide()
 	end
+
 --[[
 print("TRepair eq cost"
 	.." "..tostring(equipped)..""
@@ -198,12 +261,16 @@ end
 -- **************************************************************************
 --]]
 local function Scan(reason, force)
+--[==[
+local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, reforging, Name = string.find(itemLink, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
+print
+--]==]
 	local must_do = force or false
 	local milli = GetTime() -- seconds with millisecond precision (float)
 	local dmsg = ""
 	local msg = "Scan "

-	if (TR.show_debug) then
+	if (TR.show_debug or TR.show_debug_scan) then
 		msg = msg
 		.." '"..tostring(reason).."'"
 		.." "..string.format("%0.2F",(milli - TR.last_scan)).." sec"
@@ -215,7 +282,7 @@ local function Scan(reason, force)
 		local sell_gray = TitanGetVar(TITAN_REPAIR_ID,"SellAllGray")
 		local calc_gray = (show_gray or sell_gray) -- either needs a scan to calc

-		if (TR.show_debug) then
+		if (TR.show_debug_scan) then
 			msg = msg.." : running "
 				.." force:"..tostring(force)..""
 				.." inv:"..tostring(calc_inv)..""
@@ -226,77 +293,137 @@ local function Scan(reason, force)

 		-- Init the repair tables - equip / bags / grays
 		RepairInit()
-
+
 		-- ++++++++++++++++++++++++++++++++++++++++++++++++++
 		-- scan equipped items - only those with durability
 		--
-		if (TR.show_debug) then
+		if (TR.show_debug_scan) then
 			dmsg = "Start equip scan"
 				.." - "..(TitanGetVar(TITAN_REPAIR_ID,"ShowUndamaged") and "Include Undamaged" or "Only Damaged")
 			debug_msg(dmsg)
 		end

 		local itemName, _, itemQuality
-		for slotName, slotID in pairs(Enum.InventoryType) do
+
+		-- Walk thru slots 'backward' to give weapons 'priority' if most damagaged
+		for slotID = TR.scan_start, TR.scan_end, -1 do  -- thru slots
+			local slotName = slots[slotID].name
+			local scan_slots = tostring(slotName)..":"..tostring(GetInventorySlotInfo(slotName))
+
 			local hasItem = {}
 			local repairCost = 0
 			local dbg_str_01 = ""

-			local minimum, maximum = GetInventoryItemDurability(slotID)
+			local _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, reforging, Name
+			local itemName, itemQuality
+
+			local itemLink = GetInventoryItemLink("player", slotID)

-			if minimum and maximum then
-				-- 	Only when item has durability
+			scan_slots = scan_slots
+				.." link:"..tostring((itemLink and true or false))..""

-				hasItem, repairCost = GetRepairCostEquip(slotName, slotID)
-				if hasItem then
-					local itemLink = GetInventoryItemLink("player", slotID)
+			if itemLink == nil then
+				-- slot is empty
+				scan_slots = scan_slots
+					.." item: Empty"
+			else
+				_, _, Color, Ltype, Id, Enchant,
+					Gem1, Gem2, Gem3, Gem4,
+					Suffix, Unique, LinkLvl, reforging, Name = string.find(itemLink, parse_item)
+				itemName, _, itemQuality = GetItemInfo(Id)
+
+				scan_slots = scan_slots
+					.." id:"..tostring(Id)..""
+					.." '"..tostring(itemName).."'"

-					if itemLink then
-						itemName, _, itemQuality = GetItemInfo(itemLink)
+				if Id == nil or itemName == nil then -- item data should be good
+					-- likely entering world, server has not fully sent data to use
+					if (TR.show_debug or TR.show_debug_scan) then
+						scan_slots = scan_slots
+							..TitanUtils_GetRedText(" scan: in 1 sec")
+							.." on:"..tostring(TR_Timer_active)..""
+						debug_msg(scan_slots)
+					end
+--					if TR_Timer_active then
+						-- Let the existing timer run
+--					else
+						TR_Timer_active = true
+						TR_Timer = AceTimer.ScheduleTimer(TITAN_BUTTON, TitanRepair_ScanShell, 1.0)
+--					end
+					return -- harsh but best...
+				else
+					local minimum, maximum = GetInventoryItemDurability(slotID)
+					if minimum and maximum then -- Only calc when item has durability
+						local hasItem, repairCost = GetRepairCostEquip(slotName, slotID)
 						local r, g, b, hex = GetItemQualityColor(itemQuality or 1)
+
+						scan_slots = scan_slots
+							.." item:"..tostring(hasItem)..""
+							.." $:"..tostring(repairCost)..""
+
 						-- save item for tooltip and debug
 						if ((repairCost and repairCost > 0) or TitanGetVar(TITAN_REPAIR_ID,"ShowUndamaged")) then
 							TR.equip_list[slotName] = {
 												name = (itemName or UNKNOWN),
 												quality = (itemQuality or UNKNOWN),
 												color = (hex or UNKNOWN),
-												dur_max = (maximum or UNKNOWN),
-												dur_cur = (minimum or UNKNOWN),
+												dur_max = (maximum or 0),
+												dur_cur = (minimum or 0),
 												dur_per = ((maximum > 0 and floor(minimum / maximum * 100)) or 100),
 												cost = (repairCost or 0),
 												}
-							-- debug
-							if TR.show_debug_scan then
-								dbg_str_01 = tostring(slotName)..":"..tostring(slotId)
-												.." '"..tostring(TR.equip_list[slotName].name).."'"
-												.." "..tostring(TR.equip_list[slotName].quality)
-												.." "..tostring(TR.equip_list[slotName].cost)
-												.." "..tostring(TR.equip_list[slotName].dur_per).."%"
-												.." "..tostring(TR.equip_list[slotName].dur_cur)
-												.."/"..tostring(TR.equip_list[slotName].dur_max)
-								debug_msg(dbg_str_01)
+
+							scan_slots = scan_slots
+								.." %:"..tostring(TR.equip_list[slotName].dur_per)..""
+								.." ["..tostring(minimum)..""
+								..":"..tostring(maximum).."]"
+
+							-- Get most damaged by finding least %
+							if 	TR.equip_list[slotName].dur_per < TR.equip_most.dur_per
+							then
+								TR.equip_most = {
+									name = TR.equip_list[slotName].name,
+									quality = TR.equip_list[slotName].quality,
+									color = TR.equip_list[slotName].color,
+									dur_max = TR.equip_list[slotName].dur_max,
+									dur_cur = TR.equip_list[slotName].dur_cur,
+									dur_per = TR.equip_list[slotName].dur_per,
+									cost = TR.equip_list[slotName].cost,
+									}
+								scan_slots = scan_slots
+									..TitanUtils_GetNormalText(" <:"..tostring(TR.equip_most.dur_per))..""
 							else
-								-- not requested
+								-- not most damaged
 							end
+						else
+							-- nothing
 						end
+
+						TR.repair_total = TR.repair_total + repairCost
+						TR.repair_equip.total = TR.repair_equip.total + repairCost
+
+						TR.repair_equip.cur = TR.repair_equip.cur + minimum
+						TR.repair_equip.max = TR.repair_equip.max + maximum
 					else
-						-- nothing
+						-- some equipped items do not have durability
 					end
-
-					TR.repair_total = TR.repair_total + repairCost
-					TR.repair_equip.total = TR.repair_equip.total + repairCost
 				end
+			end

-				TR.repair_equip.cur = TR.repair_equip.cur + minimum
-				TR.repair_equip.max = TR.repair_equip.max + maximum
-
+			scan_slots = scan_slots
+				.." total :"..tostring(TR.repair_equip.total)..""
+
+			if TR.show_debug_scan then
+				debug_msg(scan_slots)
 			else
-				-- some equipped items do not have durability
+				-- not requested
 			end
-		end -- InventoryType
+
+
+		end -- for
 		TR.repair_equip.dur = (TR.repair_equip.max > 0 and floor(TR.repair_equip.cur / TR.repair_equip.max * 100)) or 100

-		if (TR.show_debug) then
+		if (TR.show_debug or TR.show_debug_scan) then
 			dmsg = "End equip scan "
 				.." $"..tostring(TR.repair_equip.total)
 				.." "..tostring(TR.repair_equip.dur).."%"
@@ -357,15 +484,19 @@ local function Scan(reason, force)
 				debug_msg(dmsg)
 			end
 		else
-			debug_msg("Bags repair totals None - User did not request")
+			if (TR.show_debug) then
+				debug_msg("Bags repair totals None - User did not request")
+			end
 		end
 		if (TR.show_debug) then
 			if calc_gray then -- calc total grays - if requested by user.
 				dmsg = "Bags gray scan End "
 					.." $ "..tostring(TR.grays.total)
-				debug_msg(dmsg)
 			else
-				debug_msg("Bags gray totals None - User did not request")
+				dmsg = "Bags gray totals None - User did not request"
+			end
+			if TR.show_debug then
+				debug_msg(dmsg)
 			end
 		end

@@ -404,6 +535,11 @@ local function Scan(reason, force)
 	end
 end

+function TitanRepair_ScanShell()
+	Scan("Timer initiated", true)
+	TR_Timer_active = false
+end
+
 --[[ local
 -- **************************************************************************
 -- NAME : RepairShow()
@@ -412,7 +548,9 @@ end
 -- **************************************************************************
 --]]
 local function RepairShow(self)
-	debug_msg("RepairShow - starting")
+	if TR.show_debug then
+		debug_msg("RepairShow - starting")
+	end
 	RepairInit()

 	self:RegisterEvent("MERCHANT_SHOW");
@@ -424,7 +562,9 @@ local function RepairShow(self)
 	-- Check everything on world enter (at init and after zoning)
 	Scan("OnShow", true)

-	debug_msg("...RepairShow - complete")
+	if TR.show_debug then
+		debug_msg("...RepairShow - complete")
+	end
 end

 --[[ local
@@ -435,7 +575,9 @@ end
 -- **************************************************************************
 --]]
 local function RepairHide(self)
-	debug_msg("RepairHide - shutting down")
+	if TR.show_debug then
+		debug_msg("RepairHide - shutting down")
+	end
 	RepairInit() -- cleanup footprint

 	self:UnregisterEvent("MERCHANT_SHOW");
@@ -444,7 +586,9 @@ local function RepairHide(self)
 	self:UnregisterEvent("UNIT_INVENTORY_CHANGED");
 	self:UnregisterEvent("UPDATE_INVENTORY_DURABILITY");

-	debug_msg("...RepairHide - complete")
+	if TR.show_debug then
+		debug_msg("...RepairHide - complete")
+	end
 end

 --[[ local
@@ -532,7 +676,9 @@ Jul 2023 / 10.1.5
 - Button name change MerchantGuildBankRepairButtonIcon > MerchantGuildBankRepairButton
 Realized the Disable also changes the button so the DeSat is redundent
 --]=]
-	debug_msg("_RepairItems")
+	if TR.show_debug then
+		debug_msg("_RepairItems")
+	end
 	-- New RepairAll function
 	local cost = GetRepairAllCost();
 	local money = GetMoney();
@@ -570,10 +716,12 @@ Realized the Disable also changes the button so the DeSat is redundent
 			DEFAULT_CHAT_FRAME:AddMessage(_G["GREEN_FONT_COLOR_CODE"]..L["TITAN_REPAIR"]..": ".."|r"..L["TITAN_REPAIR_GBANK_NORIGHTS"])
 		end
 	else -- Use own funds
-		debug_msg("Use own gold "
-			.." $"..tostring(cost)..""
-			.." gold: "..tostring(money)
-			)
+		if TR.show_debug then
+			debug_msg("Use own gold "
+				.." $"..tostring(cost)..""
+				.." gold: "..tostring(money)
+				)
+		end
 		if money > cost then
 			RepairAllItems()
 			-- report repair cost to chat (optional)
@@ -601,7 +749,9 @@ end
 -- **************************************************************************
 --]]
 local function TitanRepair_SellGrayItems()
-	debug_msg("Selling gray items")
+	if TR.show_debug then
+		debug_msg("Selling gray items")
+	end

 	for bag = 0, 4 do
 		for slot = 1, C_Container.GetContainerNumSlots(bag) do
@@ -707,6 +857,8 @@ function TitanPanelRepairButton_OnLoad(self)
 		savedVariables = {
 			ShowIcon = 1,
 			ShowLabelText = 1,
+			ShowMostDamaged = false,
+			ShowTotals = true,
 			ShowUndamaged = false,
 			ShowPopup = false,
 			AutoRepair = false,
@@ -740,11 +892,13 @@ end
 --]]
 function TitanPanelRepairButton_OnEvent(self, event, a1, ...)

-	local msg = "Event"
-		.." "..tostring(event)
-		.." "..tostring(a1)
-		.."..."
-	debug_msg(msg)
+	if TR.show_debug then
+		local msg = "Event"
+			.." "..tostring(event)
+			.." "..tostring(a1)
+			.."..."
+		debug_msg(msg)
+	end

 	if (event == "PLAYER_REGEN_ENABLED")
 	or (event == "UNIT_INVENTORY_CHANGED" and a1 == "player")
@@ -799,10 +953,12 @@ function TitanPanelRepairButton_OnEvent(self, event, a1, ...)
 		self:UnregisterEvent("PLAYER_MONEY");
 	end

-	local msg = "...Event"
-		.." "..tostring(event)
-		.." ".."complete"
-	debug_msg(msg)
+	if TR.show_debug then
+		local msg = "...Event"
+			.." "..tostring(event)
+			.." ".."complete"
+		debug_msg(msg)
+	end
 end

 function TitanPanelRepairButton_OnClick(self, button)
@@ -822,41 +978,11 @@ function TitanPanelRepairButton_OnClick(self, button)
 	end
 end

---[[ Titan
--- **************************************************************************
--- NAME : TitanPanelRepairButton_GetButtonText(id)
--- DESC : Determine the plugin button text based on last scan values and user preferences
--- VARS : id = plugin id (Repair)
--- OUT :
--- string : plugin label
--- string : plugin text / values
--- **************************************************************************
---]]
-function TitanPanelRepairButton_GetButtonText(id)
-	local text, itemLabel = "", "" -- TitanRepair_GetStatusStr(TR.INDEX, 1);
-	local itemNamesToShow = "";
-	local itemPercent = 0
-	local itemCost = 0
-
-	-- supports turning off labels
-	if TR.scan_running then
-		return L["REPAIR_LOCALE"]["button"],
-			text .. " (" .. L["REPAIR_LOCALE"]["WholeScanInProgress"] .. ")";
-	else
+local function GetDiscountCost(sum)
 		local costStr = 0;
 		local discountlabel = "";
-
-		-- calculate the totals
-		dura_total = TR.dur_total
-		bags_dur = TR.repair_bags.dur
-		equip_dur = TR.repair_equip.dur
-
-		text = string.format("%d%%", dura_total);
-		text = AutoHighlight (dura_total, text);
-		text = text.." " -- total %
-
 		-- show cost per the user choice
-		local sum = TR.repair_total
+
 		if (sum > 0 and TitanGetVar(TITAN_REPAIR_ID,"ShowRepairCost")) then
 			-- if a discount was requested by user
 			if TitanGetVar(TITAN_REPAIR_ID, "DiscountFriendly") then
@@ -872,32 +998,114 @@ function TitanPanelRepairButton_GetButtonText(id)
 				sum = sum * 0.80;
 				discountlabel = FACTION_STANDING_LABEL8;
 			end
-			costStr = "(".. GetTextGSC(sum)..") ";
-			discountlabel = GREEN_FONT_COLOR_CODE..discountlabel..FONT_COLOR_CODE_CLOSE.." "
+			costStr = "(".. GetTextGSC(sum)..")";
+			discountlabel = " "..GREEN_FONT_COLOR_CODE..discountlabel..FONT_COLOR_CODE_CLOSE
 		else
 			-- user does not want to see cost; clear the reputation also
 			costStr = ""
 			discountlabel = ""
 		end
+
+		return costStr, discountlabel
+end
+
+--[[ Titan
+-- **************************************************************************
+-- NAME : TitanPanelRepairButton_GetButtonText(id)
+-- DESC : Determine the plugin button text based on last scan values and user preferences
+-- VARS : id = plugin id (Repair)
+-- OUT :
+-- string : plugin label
+-- string : plugin text / values
+-- **************************************************************************
+--]]
+function TitanPanelRepairButton_GetButtonText(id)
+	local itemNamesToShow = ""
+	local itemPercent = 0
+	local itemCost = 0
+	local res = ""
+	local msg = "Repair _text"
+
+	local totals = TitanGetVar(TITAN_REPAIR_ID,"ShowTotals")
+	local dmg = TitanGetVar(TITAN_REPAIR_ID,"ShowMostDamaged")
+	local gray = TitanGetVar(TITAN_REPAIR_ID,"ShowGray")
+
+	if (TR.show_debug) then
+		msg = msg.." : running "
+			.." totals:"..tostring(totals)..""
+			.." dmg:"..tostring(dmg)..""
+			.." gray:"..tostring(gray)..""
+		debug_msg(msg)
+	end
+
+	-- supports turning off labels
+
+	if TR.scan_running then
+		res = text.." ("..L["REPAIR_LOCALE"]["WholeScanInProgress"]..")"

+		if (TR.show_debug) then
+			debug_msg(res)
+		end
+
+		return L["REPAIR_LOCALE"]["button"], res
+	else
+		-- ======
+		-- Get repair totals
+		local text_label = ""
+		local text = ""
+		if (TitanGetVar(TITAN_REPAIR_ID,"ShowTotals")) then
+			text_label = L["REPAIR_LOCALE"]["button"]
+			dura_total = TR.dur_total
+			text = string.format("%d%%", dura_total)
+			text = AutoHighlight(dura_total, text)
+			text = text.." " -- total %
+
+			-- show cost per the user choice
+			local costStr, discountlabel = GetDiscountCost(TR.repair_total)
+			text = text..costStr..discountlabel
+		else
+			-- not requested
+		end
+
+		-- ======
+		-- Get most damaged
+		local most_label = ""
+		local most = ""
+		if (TitanGetVar(TITAN_REPAIR_ID,"ShowMostDamaged")) then
+			most_label = L["REPAIR_LOCALE"]["mostdamaged"]..": "
+			if TR.equip_most.name == UNKNOWN then
+				-- nothing damaged
+				most = TitanUtils_GetNormalText((NONE or "None"))
+			else
+				most = string.format("%d%%", TR.equip_most.dur_per)
+				most = AutoHighlight (TR.equip_most.dur_per, most)
+
+				-- name with color
+				most = most.." ".."|c"..TR.equip_most.color..TR.equip_most.name.._G["FONT_COLOR_CODE_CLOSE"]
+			end
+		else
+			-- not requested
+		end
+
+		-- ======
+		-- calculate gray totals
 		local gray_header = ""
 		local gray_total = ""
 		if (TitanGetVar(TITAN_REPAIR_ID,"ShowGray")) then
 			gray_header = ITEM_QUALITY0_DESC..": " -- Poor / gray
 			gray_total = GetTextGSC(TR.grays.total)
 		else
-			-- user does not want to see cost; clear the reputation also
-			gray_header = ""
-			gray_total = ""
 		end
+
+		if (TR.show_debug) then
+			msg = text.." "..most.." "..gray_total
+			debug_msg(msg)
+		end
+
 		-- Now that the pieces have been created, return the whole string
-		return L["REPAIR_LOCALE"]["button"],
-			text
-			..costStr
-			..discountlabel
-			..itemNamesToShow,
-			gray_header,
-			gray_total
+		return text_label, text,
+			most_label, most,
+			gray_header, gray_total
 	end
 end

@@ -912,7 +1120,7 @@ function TitanPanelRepairButton_GetTooltipText()
 	local cost = 0;
 	local sum = TR.repair_total

-	if TR.show_debug then
+	if TR.show_debug_tooltip then
 		local msg = "Tooltip Start "
 			.." items:"..tostring(TitanGetVar(TITAN_REPAIR_ID,"ShowItems"))
 			.." discounts:"..tostring(TitanGetVar(TITAN_REPAIR_ID,"ShowDiscounts"))
@@ -928,20 +1136,24 @@ function TitanPanelRepairButton_GetTooltipText()

 		local num_items = 0
 		-- walk items saved from the scan
-		for slotName, slotID in pairs(Enum.InventoryType) do
+--		for slotName, sID in pairs(Enum.InventoryType) do
+		for slotID = TR.scan_end, TR.scan_start, 1 do  -- thru slots
+			local slotName = slots[slotID].name
 			if TR.equip_list[slotName] then
 				-- determine the percent or value per user request
 				local valueText = ""
---[[
-				msg = ""
-					.." '"..tostring(slotName).."'"
-					.." '"..tostring(TR.equip_list[slotName].name).."'"
-					.." "..tostring(TR.equip_list[slotName].quality)
-					.." "..tostring(TR.equip_list[slotName].cost)
-					.." "..tostring(TR.equip_list[slotName].dur_per).."%"
-					.." "..tostring(TR.equip_list[slotName].dur_cur)
-					.."/"..tostring(TR.equip_list[slotName].dur_max)
-				debug_msg(msg)
+---[[
+				if TR.show_debug_tooltip then
+					msg = ""
+						.." '"..tostring(slotName).."'"
+						.." '"..tostring(TR.equip_list[slotName].name).."'"
+						.." "..tostring(TR.equip_list[slotName].quality)
+						.." "..tostring(TR.equip_list[slotName].cost)
+						.." "..tostring(TR.equip_list[slotName].dur_per).."%"
+						.." "..tostring(TR.equip_list[slotName].dur_cur)
+						.."/"..tostring(TR.equip_list[slotName].dur_max)
+					debug_msg(msg, TR.show_debug_tooltip)
+				end
 --]]
 				if (TitanGetVar(TITAN_REPAIR_ID,"ShowPercentage")) then
 					valueText = string.format("%d%%", TR.equip_list[slotName].dur_per)
@@ -968,7 +1180,9 @@ function TitanPanelRepairButton_GetTooltipText()
 			-- All items are at 100%
 			out = out..TitanUtils_GetHighlightText("No items damaged").."\n"
 		end
-		debug_msg(tostring("Items shown : "..num_items))
+		if TR.show_debug_tooltip then
+			debug_msg(tostring("Items shown : "..num_items))
+		end
 	end

 	out = out.."\n" -- spacer
@@ -1140,6 +1354,24 @@ function TitanPanelRightClickMenu_PrepareRepairMenu()
 			TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_OPTIONS"], TitanPanelRightClickMenu_GetDropdownLevel());

 			info = {};
+			info.text = SHOW.." "..(TOTAL or "Totals")
+			info.func = function()
+				TitanToggleVar(TITAN_REPAIR_ID, "ShowTotals")
+				TitanPanelButton_UpdateButton(TITAN_REPAIR_ID)
+				end
+			info.checked = TitanGetVar(TITAN_REPAIR_ID,"ShowTotals")
+			TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel())
+
+			info = {};
+			info.text = L["REPAIR_LOCALE"]["mostdamaged"]
+			info.func = function()
+				TitanToggleVar(TITAN_REPAIR_ID, "ShowMostDamaged")
+				TitanPanelButton_UpdateButton(TITAN_REPAIR_ID)
+				end
+			info.checked = TitanGetVar(TITAN_REPAIR_ID,"ShowMostDamaged")
+			TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel())
+
+			info = {};
 			info.text = L["REPAIR_LOCALE"]["showinventory"];
 			info.func = function()
 				TitanToggleVar(TITAN_REPAIR_ID, "ShowInventory");
@@ -1372,5 +1604,6 @@ end
 if TITAN_ID then -- it exists
 	L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true)
 	TitanRepair = LibStub("AceAddon-3.0"):NewAddon(TITAN_REPAIR_ID, "AceHook-3.0", "AceTimer-3.0")
+	TR_Timer = LibStub("AceTimer-3.0")
 	Create_Frames() -- do the work
 end