changeset 69:69db1c3025ac v27

fixed some bugs with 6.2 item link format changes, added bib overwolf support
author yellowfive
date Mon, 06 Jul 2015 17:39:57 -0700
parents 6c523f147709
children 8af362b95d2f
files AskMrRobot-Serializer/AskMrRobot-Serializer.lua AskMrRobot.toc CombatLog.lua Constants.lua Core.lua Export.lua Gear.lua Import.lua Media/IconClose.tga Media/IconCloseOver.tga localization/enUS.lua localization/frFR.lua localization/itIT.lua ui/AmrUiFrame.lua
diffstat 14 files changed, 158 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/AskMrRobot-Serializer/AskMrRobot-Serializer.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -1,7 +1,7 @@
 -- AskMrRobot-Serializer will serialize and communicate character data between users.
 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com.
 
-local MAJOR, MINOR = "AskMrRobot-Serializer", 26
+local MAJOR, MINOR = "AskMrRobot-Serializer", 27
 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
 
 if not Amr then return end -- already loaded by something else
@@ -579,7 +579,7 @@
 -- Public Utility Methods
 ----------------------------------------------------------------------------------------
 
--- item link format:  |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
+-- item link format:  |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:unknown:unknown:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
 -- get an object with all of the parts of the item link format that we care about
 function Amr.ParseItemLink(itemLink)
     if not itemLink then return nil end
@@ -597,7 +597,7 @@
     --item.uniqueId = tonumber(parts[8])
     --item.level = tonumber(parts[9])
 	-- part 10 is unknown atm
-    item.upgradeId = tonumber(parts[11])
+	-- part 11 is unknown atm
     --item.difficultyId = tonumber(parts[12])
     
     local numBonuses = tonumber(parts[13])
@@ -608,6 +608,14 @@
         end
 		table.sort(item.bonusIds)
     end
+	
+	-- if numBonuses is 0 and there is a number after it, that is the upgrade id for old items now I guess?
+	if numBonuses == 0 then
+		local upgradeId = tonumber(parts[14])
+		item.upgradeId = upgradeId and upgradeId or 0
+	else
+		item.upgradeId = 0
+	end
     
     return item
 end
--- a/AskMrRobot.toc	Mon Jun 29 17:06:02 2015 -0700
+++ b/AskMrRobot.toc	Mon Jul 06 17:39:57 2015 -0700
@@ -1,7 +1,7 @@
 ## Interface: 60200
 ## Title: Ask Mr. Robot
 ## Author: Team Robot, Inc.
-## Version: 26
+## Version: 27
 ## Notes: Gear import/export, combat logging, and more.
 ## URL: www.askmrrobot.com
 ## SavedVariables: AskMrRobotDb2
--- a/CombatLog.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/CombatLog.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -216,6 +216,32 @@
 	_autoChecks = nil
 end
 
+-- update the game's logging state
+local function updateGameLogging(enabled)
+	if enabled then
+		-- always enable advanced combat logging via our addon, gathers more detailed data for better analysis
+		SetCVar("advancedCombatLogging", 1)
+		LoggingCombat(true)
+	else
+		LoggingCombat(false)
+	end
+end
+
+local function isAnyAutoLoggingEnabled()
+	local anyChecked = false
+	for i, instanceId in ipairs(Amr.InstanceIdsOrdered) do
+		for k, difficultyId in pairs(Amr.Difficulties) do
+			if Amr.db.profile.Logging.Auto[instanceId][difficultyId] then
+				anyChecked = true
+				break
+			end
+		end
+		if anyChecked then break end
+	end
+	
+	return anyChecked
+end
+
 local function isAllAutoLoggingEnabled()
 	-- see if all auto-logging options are enabled
 	local allChecked = true
@@ -233,11 +259,26 @@
 end
 
 -- check current zone and auto-logging settings, and enable logging if appropriate
-local function updateAutoLogging(force)
+local function updateAutoLogging(force, noWait)
+	
+	local hasAuto = isAnyAutoLoggingEnabled()
+	
+	-- before doing anything, make sure logging matches the user's current setting, deals with any inconsistency due to a crash or disconnect
+	if hasAuto then
+		updateGameLogging(Amr:IsLogging())
+	end
 	
 	-- get the info about the instance
 	local zone, _, difficultyId, _, _, _, _, instanceId = GetInstanceInfo()
 
+	if Amr.IsSupportedInstanceId(instanceId) and difficultyId == 0 and not noWait then
+		-- the game is sometimes returning no difficulty id for raid zones... not sure why, wait 10 seconds and check again
+		Amr.Wait(10, function()
+			updateAutoLogging(false, false)
+		end)
+		return
+	end
+	
 	if not force and zone == Amr.db.char.Logging.LastZone and difficultyId == Amr.db.char.Logging.LastDiff then
 	  -- do nothing if the zone hasn't actually changed, otherwise we may override the user's manual enable/disable
 		return
@@ -248,11 +289,12 @@
 
 	if Amr.IsSupportedInstanceId(instanceId) and Amr.db.profile.Logging.Auto[tonumber(instanceId)][tonumber(difficultyId)] then
 		-- we are in a supported zone that we want to auto-log, turn logging on 
+		
 		-- (supported check is probably redundant, but just in case someone has old settings lying around)
 		if not Amr:IsLogging() then
 			Amr:StartLogging()
 		end
-	else
+	elseif hasAuto then
 		-- not in a zone that we want to auto-log, turn logging off
 		if Amr:IsLogging() then
 			Amr:StopLogging()
@@ -358,9 +400,8 @@
 		Amr.db.char.Logging.LastWipe = nil
 	end
 
-	-- always enable advanced combat logging via our addon, gathers more detailed data for better analysis
-	SetCVar("advancedCombatLogging", 1)
-	LoggingCombat(true)
+	-- enable game log file
+	updateGameLogging(true)
 	Amr.db.char.Logging.Enabled = true
 	
 	self:Print(L.LogChatStart)
@@ -371,7 +412,7 @@
 
 function Amr:StopLogging()
 	
-	LoggingCombat(false)
+	updateGameLogging(false)
 	Amr.db.char.Logging.Enabled = false
 	
 	self:Print(L.LogChatStop)
--- a/Constants.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/Constants.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -146,18 +146,25 @@
         table.insert(parts, -math.abs(itemObj.suffixId))
     end
     
-    table.insert(parts, 0)
+    table.insert(parts, 0) -- some unique id, doesn't seem to matter
     table.insert(parts, UnitLevel("player"))
 	table.insert(parts, 0) -- unknown
-    table.insert(parts, itemObj.upgradeId)
-    table.insert(parts, 0)
+    table.insert(parts, 0) -- unknown
+    table.insert(parts, 0) -- difficulty id, doesn't matter
     
     if itemObj.bonusIds then
         table.insert(parts, #itemObj.bonusIds)
         for i,v in ipairs(itemObj.bonusIds) do
             table.insert(parts, v)
         end
+	else
+		table.insert(parts, 0) -- no bonus ids
     end
+	
+	-- upgrade id is tacked onto the end now it seems
+	if (not itemObj.bonusIds or #itemObj.bonusIds == 0) and itemObj.upgradeId and itemObj.upgradeId ~= 0 then
+		table.insert(parts, itemObj.upgradeId)
+	end
     
     return table.concat(parts, ":")
 end
--- a/Core.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/Core.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -650,6 +650,14 @@
 ----------------------------------------------------------------------------------------
 -- Debugging
 ----------------------------------------------------------------------------------------
+function Amr:Test()
+
+	local s = "|cff0070dd|Hitem:127224:5337:0:0:0:0:0:0:100:105:512:22:2:615:656:100|h[Staff of Polarities]|h|r"
+	Amr.GetItemInfo(s, function(obj, name, link, quality, iLevel)
+		print(iLevel)
+	end)
+end
+
 --[[
 function Amr:Test(val1, val2, val3)
 
--- a/Export.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/Export.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -19,6 +19,15 @@
 	Amr.db.char.FirstUse = false
 end
 
+local function onTextChanged(widget)
+	local val = _txt:GetText()
+	if val == "overwolf-bib" then
+		-- go to the gear tab, open import window, and show a cover
+		Amr:ShowTab("Gear")
+		Amr:ShowImportWindow(true)
+	end
+end
+
 -- render a splash screen with first-time help
 local function renderSplash(container)
 	local panel = Amr:RenderCoverChrome(container, 700, 450)
@@ -80,6 +89,7 @@
 	_txt:SetHeight(300)
 	_txt:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -20)
 	_txt:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text))
+	_txt:SetCallback("OnTextChanged", onTextChanged)
 	container:AddChild(_txt)
 	
 	local data = self:ExportCharacter()	
--- a/Gear.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/Gear.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -666,18 +666,19 @@
 		old = Amr.ParseItemLink(old)
 		
 		local new = gear[slotId]
-		
-		local diff = countItemDifferences(old, new)
-		if diff < 1000 then
-			-- same item, see if inventory has one that is closer (e.g. a duplicate item with correct enchants/gems)
-			local bestLink, bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems)
-			if bestDiff and bestDiff < diff then
+		if new then
+			local diff = countItemDifferences(old, new)
+			if diff < 1000 then
+				-- same item, see if inventory has one that is closer (e.g. a duplicate item with correct enchants/gems)
+				local bestLink, bestItem, bestDiff = Amr:FindMatchingItem(new, player, usedItems)
+				if bestDiff and bestDiff < diff then
+					itemsToEquip[slotId] = new
+					remaining = remaining + 1
+				end
+			else
 				itemsToEquip[slotId] = new
 				remaining = remaining + 1
 			end
-		else
-			itemsToEquip[slotId] = new
-			remaining = remaining + 1
 		end
 	end
 
--- a/Import.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/Import.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -4,6 +4,7 @@
 
 local _txtImport
 local _lblError
+local _panelCover
 
 local function onImportOkClick(widget)
 	local txt = _txtImport:GetText()
@@ -21,7 +22,22 @@
 	Amr:HideCover()
 end
 
-local function renderImportWindow(container)
+local function onTextEnterPressed(widget)
+	-- hide the overwolf cover when import data is received
+	if _panelCover then
+		_panelCover:SetVisible(false)
+	end
+	
+	-- do an import if the data starts and ends with a dollar sign
+	local txt = _txtImport:GetText()
+	local txtLen = string.len(txt)
+	if txtLen > 2 and string.sub(txt, 1, 1) == '$' then	
+		onImportOkClick()
+	end
+	
+end
+
+local function renderImportWindow(container, fromOverwolf)
 
 	local panelImport = Amr:RenderCoverChrome(container, 700, 450)
 	
@@ -36,6 +52,7 @@
 	_txtImport:SetHeight(300)
 	_txtImport:SetPoint("TOP", lbl.frame, "BOTTOM", 0, -10)
 	_txtImport:SetFont(Amr.CreateFont("Regular", 12, Amr.Colors.Text))
+	_txtImport:SetCallback("OnEnterPressed", onTextEnterPressed)
 	panelImport:AddChild(_txtImport)
 	
 	local btnImportOk = AceGUI:Create("AmrUiButton")
@@ -65,11 +82,36 @@
 	_lblError:SetPoint("TOPLEFT", btnImportOk.frame, "BOTTOMLEFT", 0, -20)
 	panelImport:AddChild(_lblError)
 	
+	if fromOverwolf then
+		-- show a cover preventing interaction until we receive data from overwolf
+		_panelCover = AceGUI:Create("AmrUiPanel")
+		_panelCover:SetLayout("None")
+		_panelCover:EnableMouse(true)
+		_panelCover:SetBackgroundColor(Amr.Colors.Black, 0.75)
+		_panelCover:SetPoint("TOPLEFT", panelImport.frame, "TOPLEFT")
+		_panelCover:SetPoint("BOTTOMRIGHT", panelImport.frame, "BOTTOMRIGHT")
+		panelImport:AddChild(_panelCover)
+
+		local coverMsg = AceGUI:Create("AmrUiLabel")
+		coverMsg:SetWidth(500)
+		coverMsg:SetFont(Amr.CreateFont("Regular", 16, Amr.Colors.TextTan))
+		coverMsg:SetJustifyH("MIDDLE")
+		coverMsg:SetJustifyV("MIDDLE")
+		coverMsg:SetText(L.ImportOverwolfWait)
+		coverMsg:SetPoint("CENTER", _panelCover.frame, "CENTER", 0, 20)
+		_panelCover:AddChild(coverMsg)
+		
+		-- after adding, set cover to sit on top of everything
+		_panelCover:SetStrata("FULLSCREEN_DIALOG")
+		_panelCover:SetLevel(Amr.FrameLevels.Highest)		
+	end
 end
 
-function Amr:ShowImportWindow()
+function Amr:ShowImportWindow(fromOverwolf)
 	-- this is shown as a modal dialog
-	Amr:ShowCover(renderImportWindow)
+	Amr:ShowCover(function(container)
+		renderImportWindow(container, fromOverwolf)
+	end)
 	
 	_txtImport:SetText("")
 	_txtImport:SetFocus(true)
Binary file Media/IconClose.tga has changed
Binary file Media/IconCloseOver.tga has changed
--- a/localization/enUS.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/localization/enUS.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -200,6 +200,8 @@
 L.ImportErrorFaction = "It looks your faction may have changed.  Please go the website and re-optimize."
 L.ImportErrorLevel = "It looks your level may have changed.  Please go the website and re-optimize."
 
+L.ImportOverwolfWait = "Performing Best in Bags optimization.  Please do not press Escape or close the addon until it has completed!"
+
 
 --[[----------------------------------------------------------------------
 Shopping List
--- a/localization/frFR.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/localization/frFR.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -200,6 +200,8 @@
 L.ImportErrorFaction = "On dirait que tu as changé de faction. Rends-toi sur le site pour ré-optimiser."
 L.ImportErrorLevel = "On dirait que tu as changé de niveau. Rends-toi sur le site pour ré-optimiser."
 
+L.ImportOverwolfWait = "Performing Best in Bags optimization.  Please do not press Escape or close the addon until it has completed!"
+
 
 --[[----------------------------------------------------------------------
 Shopping List
--- a/localization/itIT.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/localization/itIT.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -200,6 +200,8 @@
 L.ImportErrorFaction = "Sembra che la tua fazione sia cambiata.  Vai sul sito e riottimizza."
 L.ImportErrorLevel = "Sembra che il tuo livello sia cambiato.  Vai sul sito e riottimizza."
 
+L.ImportOverwolfWait = "Performing Best in Bags optimization.  Please do not press Escape or close the addon until it has completed!"
+
 
 --[[----------------------------------------------------------------------
 Shopping List
--- a/ui/AmrUiFrame.lua	Mon Jun 29 17:06:02 2015 -0700
+++ b/ui/AmrUiFrame.lua	Mon Jul 06 17:39:57 2015 -0700
@@ -162,18 +162,22 @@
 	bg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -_borderWidth, _borderWidth)
 
 	local btnClose = CreateFrame("Button", nil, frame)
-	btnClose:SetNormalFontObject(Amr.CreateFont("Bold", 16, Amr.Colors.White))
-	btnClose:SetText("x")
+	btnClose:SetNormalTexture("Interface\\AddOns\\" .. Amr.ADDON_NAME .. "\\Media\\IconClose")
+	btnClose:SetHighlightTexture("Interface\\AddOns\\" .. Amr.ADDON_NAME .. "\\Media\\IconCloseOver")
+	
+	--btnClose:SetNormalFontObject(Amr.CreateFont("Bold", 16, Amr.Colors.White))
+	--btnClose:SetText("x")
 	btnClose:SetWidth(22)
 	btnClose:SetHeight(22)
 	btnClose:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -4)
 	btnClose:SetScript("OnClick", buttonOnClick)
 
-	local lbl = btnClose:GetFontString()
-	lbl:ClearAllPoints()
-	lbl:SetPoint("TOP", btnClose, "TOP", -1, -2)
+	--local lbl = btnClose:GetFontString()
+	--lbl:ClearAllPoints()
+	--lbl:SetPoint("TOP", btnClose, "TOP", -1, -2)
 	
 	-- style the button similar to AmrUiButton
+	--[[
 	Amr.DropShadow(btnClose)
 
 	local tex = Amr.CreateTexture(btnClose, Amr.Colors.Red)
@@ -188,6 +192,7 @@
 	tex = Amr.CreateTexture(btnClose, Amr.Colors.White, 0.1)
 	tex:SetAllPoints(true)
 	btnClose:SetHighlightTexture(tex)
+	]]
 	
 	-- title
 	local titleFrame = CreateFrame("Frame", nil, frame)