changeset 12:5ae9ffe0cc2d

Fix: More responsive vendor highlights. New: slash commands
author Aaron Bregger
date Fri, 13 Aug 2010 14:22:40 -0500
parents cd091b82d4aa
children 4e7266527ce5
files core.lua
diffstat 1 files changed, 23 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Thu Aug 12 18:01:03 2010 -0500
+++ b/core.lua	Fri Aug 13 14:22:40 2010 -0500
@@ -11,7 +11,7 @@
     
 --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))
 
-local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0")
+local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0")
 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate")
 local tabletest = {}
  db = {}
@@ -19,24 +19,6 @@
 safer = safeRecipes
 RecipeProfit.db = db;
 
-local function deepcopy(object)
-    local lookup_table = {}
-    local function _copy(object)
-        if type(object) ~= "table" then
-            return object
-        elseif lookup_table[object] then
-            return lookup_table[object]
-        end
-        local new_table = {}
-        lookup_table[object] = new_table
-        for index, value in pairs(object) do
-            new_table[_copy(index)] = _copy(value)
-        end
-        return setmetatable(new_table, getmetatable(object))
-    end
-    return _copy(object)
-end
-
 function debugprint(val, indent)
     indent = indent or "";
     if not(type(val) == "table") then
@@ -51,12 +33,16 @@
             print(indent .. "} = {")
             debugprint(v, indent .. "    ")
             print(indent .. "}")
-        elseif(type(v) == "table") then
+        elseif(type(v) == "table") then                
             print(indent .. k .. " = {")
             debugprint(v, indent .. "    ")
             print(indent .. "}") 
         else
-            print(indent .. k .. " = " .. v)
+            if(type(v) ~= "boolean") then
+                print(indent .. k .. " = " .. v)
+            else
+                print(indent .. k .. " = " .. (v and "true" or "false"))
+            end
         end
     end
 end
@@ -155,6 +141,10 @@
         profile[k] = profile[k] or v;
     end
     
+    self:RegisterChatCommand("recipeprofit", "ShowOptions")
+    self:RegisterChatCommand("rp",           "ShowOptions")
+    self:RegisterChatCommand("profit",       "ShowOptions")
+    
     db.profile = profile
     db.storage = {}
     
@@ -205,6 +195,10 @@
     GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged")
 end
 
+function RecipeProfit:ShowOptions()
+    LibStub("AceConfigDialog-3.0"):Open("GatherMate", nil, "RecipeProfit")
+end
+
 function button_update(self)
     local buttonName = _G[self:GetName().."Name"];
     local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID());
@@ -232,13 +226,18 @@
 
 function RecipeProfit:UpdateButtons(event)
     --print("UpdateButtons", event)
+    if(not MerchantFrame:IsVisible()) then
+        --print("UpdateButtons - (Event: ", event, ") - MerchantFrame not visible.");
+        return;
+    end
+    
     for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do
         local buttonframe = _G["MerchantItem"..i];
         local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i);
         --print(index)
         if index <= GetMerchantNumItems() then
             button_update(buttonframe)
-        else
+        --[[else
             --print(i, index, GetMerchantNumItems())
             local itemButton = _G["MerchantItem"..i.."ItemButton"];
             local merchantButton = _G["MerchantItem"..i];
@@ -250,6 +249,7 @@
 			_G["MerchantItem"..i.."Name"]:SetText("");
 			_G["MerchantItem"..i.."MoneyFrame"]:Hide();
 			_G["MerchantItem"..i.."AltCurrencyFrame"]:Hide();
+            ]]
         end
     end
 end
@@ -262,6 +262,7 @@
     
     self:RegisterEvent("MERCHANT_SHOW",   "UpdateButtons")
     self:RegisterEvent("MERCHANT_UPDATE", "UpdateButtons")
+    self:RegisterEvent("BAG_UPDATE",      "UpdateButtons")
     
     RecipeProfit:DoMerge()
 end