changeset 33:4ba69d2ee252 v9

fixed bug with gem changes not appearing sometimes, mainWindow crash on startup, lua error for unknown item tooltips
author yellowfive
date Sat, 18 Oct 2014 18:13:55 -0700
parents a401dd0e200e
children 3769130aaf8d
files AskMrRobot.lua AskMrRobot.toc amr-constants.lua ui/GearComparisonTab.lua ui/ItemLinkText.lua
diffstat 5 files changed, 46 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/AskMrRobot.lua	Sat Oct 18 10:33:50 2014 -0700
+++ b/AskMrRobot.lua	Sat Oct 18 18:13:55 2014 -0700
@@ -44,17 +44,24 @@
 local _amrLDB
 local _minimapIcon
 
+function ensureMainWindow()
+    if AskMrRobot.mainWindow == nil then
+        AskMrRobot.mainWindow = AskMrRobot.AmrUI:new()
+    end
+end
+
 function AskMrRobot.eventListener:OnEvent(event, ...)
 	if event == "ADDON_LOADED" then
         local addon = select(1, ...)
         if (addon == "AskMrRobot") then
+            -- create main window if not created yet
+            ensureMainWindow()
+            
             AskMrRobot.InitializeSettings()
             AskMrRobot.InitializeMinimap()
             
             -- listen for messages from other AMR addons
-            RegisterAddonMessagePrefix(AskMrRobot.ChatPrefix)            
-
-            AskMrRobot.mainWindow = AskMrRobot.AmrUI:new()
+            RegisterAddonMessagePrefix(AskMrRobot.ChatPrefix)
         end
     
     elseif event == "UNIT_INVENTORY_CHANGED" then
@@ -98,12 +105,17 @@
         local chatPrefix, message = select(1, ...)
         local isLogging = AskMrRobot.CombatLogTab.IsLogging()
         if (isLogging and chatPrefix == AskMrRobot.ChatPrefix) then
+            -- create main window if not created yet
+            ensureMainWindow()
+            
             AskMrRobot.mainWindow.combatLogTab:ReadAddonMessage(message)
         end
         
     elseif event == "UPDATE_INSTANCE_INFO" or event == "PLAYER_DIFFICULTY_CHANGED" then
-    	AskMrRobot.mainWindow.combatLogTab:UpdateAutoLogging()
-        
+        -- create main window if not created yet
+        ensureMainWindow()
+    	
+        AskMrRobot.mainWindow.combatLogTab:UpdateAutoLogging()
 	end
  
 end
@@ -984,12 +996,13 @@
                 itemObj.socketColors = {}
                 for j = 1, string.len(tokens["c"]) do
                     table.insert(itemObj.socketColors, tonumber(string.sub(tokens["c"], j, j)))
-                end
+                end                
             end
             
             -- look for item ID duplicate info, deals with old SoO items
             if tokens["d"] then
                 itemObj.duplicateId = tonumber(tokens["d"])
+                itemInfo[itemObj.duplicateId] = itemObj
             end
             
         end
@@ -1052,10 +1065,17 @@
     end
     
     if isTest then
+    
         -- print result for debugging
-        local blah = importData[1]
-        local name, link = GetItemInfo(AskMrRobot.createItemLink(blah))
-        print(link)
+        --for k,v in pairs(importData) do
+        --    local blah = AskMrRobot.createItemLink(v)
+        --    local name, link = GetItemInfo(blah)
+        --    if link == nil then
+        --        print(blah)
+        --        print("bad item: " .. v.id)
+        --    end
+        --end
+        
         
     else
         -- we have succeeded, record the result
--- a/AskMrRobot.toc	Sat Oct 18 10:33:50 2014 -0700
+++ b/AskMrRobot.toc	Sat Oct 18 18:13:55 2014 -0700
@@ -1,7 +1,7 @@
 ## Interface: 60000
 ## Title: Ask Mr. Robot
 ## Author: Team Robot, Inc.
-## Version: 8
+## Version: 9
 ## Notes: Exports/Imports data to/from askmrrobot.com.
 ## URL: www.askmrrobot.com
 ## DefaultState: Enabled
--- a/amr-constants.lua	Sat Oct 18 10:33:50 2014 -0700
+++ b/amr-constants.lua	Sat Oct 18 18:13:55 2014 -0700
@@ -47,7 +47,13 @@
     table.insert(parts, itemObj.gemIds[2])
     table.insert(parts, itemObj.gemIds[3])
     table.insert(parts, itemObj.gemIds[4])
-    table.insert(parts, -math.abs(itemObj.suffixId))
+    
+    if itemObj.suffixId == 0 then
+        table.insert(parts, 0)
+    else
+        table.insert(parts, -math.abs(itemObj.suffixId))
+    end
+    
     table.insert(parts, 0)
     table.insert(parts, UnitLevel("player"))
     table.insert(parts, itemObj.upgradeId)
--- a/ui/GearComparisonTab.lua	Sat Oct 18 10:33:50 2014 -0700
+++ b/ui/GearComparisonTab.lua	Sat Oct 18 18:13:55 2014 -0700
@@ -318,11 +318,13 @@
                 needsUpgrade = needsUpgrade
             }
         elseif itemEquipped then
-            if AskMrRobot.ExtraItemData[itemEquipped.id] and AskMrRobot.ExtraItemData[itemEquipped.id].socketColors then
-            -- items are same, check for gem/enchant differences
-            --   NOTE: we used to do a bunch of fancy gem checks, but we can ditch all that logic b/c WoD gems are much simpler (no socket bonuses, gem/socket colors to worry about)
+        
+            if AskMrRobot.ExtraItemData[itemImported.id] and AskMrRobot.ExtraItemData[itemImported.id].socketColors then
+            
+                -- items are same, check for gem/enchant differences
+                --   NOTE: we used to do a bunch of fancy gem checks, but we can ditch all that logic b/c WoD gems are much simpler (no socket bonuses, gem/socket colors to worry about)
                 local hasBadGems = false
-                for g = 1, #AskMrRobot.ExtraItemData[itemEquipped.id].socketColors do
+                for g = 1, #AskMrRobot.ExtraItemData[itemImported.id].socketColors do
                     if not AskMrRobot.AreGemsCompatible(itemEquipped.gemIds[g], itemImported.gemIds[g]) then
                         hasBadGems = true
                         break
@@ -335,7 +337,7 @@
                         optimized = {}
                     }
 
-                    for g = 1, #AskMrRobot.ExtraItemData[itemEquipped.id].socketColors do
+                    for g = 1, #AskMrRobot.ExtraItemData[itemImported.id].socketColors do
                         result.gems[slotId].current[g] = itemEquipped.gemIds[g]
                         result.gems[slotId].optimized[g] = itemImported.gemIds[g]
                     end
--- a/ui/ItemLinkText.lua	Sat Oct 18 10:33:50 2014 -0700
+++ b/ui/ItemLinkText.lua	Sat Oct 18 18:13:55 2014 -0700
@@ -40,9 +40,9 @@
             self.itemText:SetText(itemLink:gsub("%[", ""):gsub("%]", ""))
         end
     else
-        self.itemText:SetFormattedText("unknown (%d)", itemId)
+        self.itemText:SetFormattedText("unknown (%d)", itemObj.id)
         self.itemText:SetTextColor(1,1,1)
-        AskMrRobot.RegisterItemInfoCallback(itemId, function(name, itemLink2)
+        AskMrRobot.RegisterItemInfoCallback(itemObj.id, function(name, itemLink2)
             if self.formatText then
                 self.itemText:SetFormattedText(self.formatText, itemLink2:gsub("%[", ""):gsub("%]", ""))
             else