diff AskMrRobot.lua @ 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 44c285acfff0
children d964099e4783
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