Quantcast

Added more debug messages, along with a 'Copy Log' button

James Whitehead II [08-17-08 - 12:58]
Added more debug messages, along with a 'Copy Log' button
Filename
DressToKill.lua
DressToKillOptions.lua
diff --git a/DressToKill.lua b/DressToKill.lua
index d589dc3..40e5023 100644
--- a/DressToKill.lua
+++ b/DressToKill.lua
@@ -193,9 +193,11 @@ local function scanFunction(weightFunction)
 							local oh_link = GetInventoryItemLink("player", offslot) or linen_shirt
 							local oh_score = weightFunction(oh_link, offslot) - score
 							score = score + oh_score
+							debug(L["Got score of %s for %s/%s"], score, mh_link, oh_link)
+						else
+							debug(L["Failed to equip %s"], link)
 						end

-						debug("Got score of %s for %s and %s", score, mh_link, oh_link or "empty")
 						if score >= weapon_max then
 							weapon_max = score
 							weapon_win.mh = mh_mask
@@ -204,6 +206,7 @@ local function scanFunction(weightFunction)

 						-- Unequip the offhand item
 						if oh_equipped then
+							debug(L["Unequipping %s"], link)
 							DressToKill:UnequipItem(offslot, oh_mask, oh_stash)
 						end
 					end
diff --git a/DressToKillOptions.lua b/DressToKillOptions.lua
index 697a35d..2bdb3f3 100644
--- a/DressToKillOptions.lua
+++ b/DressToKillOptions.lua
@@ -264,19 +264,17 @@ local debugframe = CreateFrame("Frame", "DressToKillDebugFrame", UIParent)
 debugframe.name = L["Debug Log"]
 debugframe.parent = L["Dress to Kill"]
 debugframe:Hide()
-debugframe:SetScript("OnShow", function(frame)
-	debugframe:SetScript("OnShow", nil)
-end)

 local scrollframe = CreateFrame("ScrollingMessageFrame", "DressToKillDebugScrollFrame", debugframe)
 scrollframe:SetPoint("TOPLEFT", 10, -10)
-scrollframe:SetPoint("BOTTOMRIGHT", -10, 10)
+scrollframe:SetPoint("BOTTOMRIGHT", -10, 45)
 scrollframe:SetFontObject("ChatFontNormal")
 scrollframe:SetJustifyH("LEFT")
 scrollframe:SetFading(false)
 scrollframe:EnableMouseWheel(true)
 scrollframe:SetInsertMode("BOTTOM")
 scrollframe:SetMaxLines(99999)
+scrollframe:AddMessage("Dress to Kill v." .. (GetAddOnMetadata("TomTom", "Version") or "unknown"))
 local function scroll(self, delta)
 	if delta > 0 then
 		if IsShiftKeyDown() then
@@ -302,3 +300,80 @@ end)
 scrollframe:SetScript("OnMouseWheel", scroll)

 InterfaceOptions_AddCategory(debugframe)
+
+debugframe:SetScript("OnShow", function(frame)
+	debugframe:SetScript("OnShow", nil)
+
+	-- Copied from Chatter by Antiarc
+	local PaneBackdrop  = {
+		bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
+		edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
+		tile = true, tileSize = 16, edgeSize = 16,
+		insets = { left = 3, right = 3, top = 5, bottom = 3 }
+	}
+
+	local InsetBackdrop  = {
+		bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],
+		edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
+		tile = true, tileSize = 16, edgeSize = 16,
+		insets = { left = 3, right = 3, top = 5, bottom = 3 }
+	}
+
+	local frame = CreateFrame("Frame", "DressToKillCopyFrame", UIParent)
+	table.insert(UISpecialFrames, "DressToKillCopyFrame")
+	frame:SetBackdrop(PaneBackdrop)
+	frame:SetBackdropColor(0,0,0,1)
+	frame:SetWidth(500)
+	frame:SetHeight(200)
+	frame:SetPoint("CENTER", UIParent, "CENTER")
+	frame:Hide()
+	frame:SetFrameStrata("DIALOG")
+
+	local scrollArea = CreateFrame("ScrollFrame", "DressToKillCopyScroll", frame, "UIPanelScrollFrameTemplate")
+	scrollArea:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -30)
+	scrollArea:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -30, 8)
+
+	local editBox = CreateFrame("EditBox", nil, frame)
+	editBox:SetMultiLine(true)
+	editBox:SetMaxLetters(99999)
+	editBox:EnableMouse(true)
+	editBox:SetAutoFocus(false)
+	editBox:SetFontObject(ChatFontNormal)
+	editBox:SetWidth(400)
+	editBox:SetHeight(270)
+	editBox:SetScript("OnEscapePressed", function() frame:Hide() end)
+
+	scrollArea:SetScrollChild(editBox)
+
+	local lines = {}
+	local function getlines(...)
+		local ct = 1
+		for i = select("#", ...), 1, -1 do
+			local region = select(i, ...)
+			if region:GetObjectType() == "FontString" then
+				lines[ct] = tostring(region:GetText())
+				ct = ct + 1
+			end
+		end
+		return ct - 1
+	end
+
+	local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
+	close:SetPoint("TOPRIGHT", frame, "TOPRIGHT")
+
+	copylog = CreateFrame("Button", "DressToKillCopyLogButton", DressToKillDebugScrollFrame, "UIPanelButtonTemplate2")
+	copylog:SetText(L["Copy Log"])
+	copylog:SetWidth(80)
+	copylog:SetPoint("TOPRIGHT", scrollframe, "BOTTOMRIGHT", 0, -5)
+	copylog:SetScript("OnClick", function(self)
+		lines = {}
+		local _, size = DressToKillDebugScrollFrame:GetFont()
+		FCF_SetChatWindowFontSize(DressToKillDebugScrollFrame, 0.01)
+		local lineCt = getlines(DressToKillDebugScrollFrame:GetRegions())
+		local text = table.concat(lines, "\n", 1, lineCt)
+		FCF_SetChatWindowFontSize(DressToKillDebugScrollFrame, size)
+		DressToKillCopyFrame:Show()
+		editBox:SetText(text)
+		editBox:HighlightText(0)
+	end)
+end)