Mercurial > wow > recipeprofit
comparison core.lua @ 12:5ae9ffe0cc2d
Fix: More responsive vendor highlights.
New: slash commands
| author | Aaron Bregger |
|---|---|
| date | Fri, 13 Aug 2010 14:22:40 -0500 |
| parents | 20e2aefac1b0 |
| children | 4e7266527ce5 |
comparison
equal
deleted
inserted
replaced
| 11:cd091b82d4aa | 12:5ae9ffe0cc2d |
|---|---|
| 9 | 9 |
| 10 http://www.wrathguides.com/ | 10 http://www.wrathguides.com/ |
| 11 | 11 |
| 12 --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--)) | 12 --]]--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--))--)) |
| 13 | 13 |
| 14 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0") | 14 local RecipeProfit = LibStub("AceAddon-3.0"):NewAddon("RecipeProfit", "AceEvent-3.0", "AceConsole-3.0") |
| 15 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate") | 15 local GatherMate = LibStub("AceAddon-3.0"):GetAddon("GatherMate") |
| 16 local tabletest = {} | 16 local tabletest = {} |
| 17 db = {} | 17 db = {} |
| 18 local safeRecipes = {} | 18 local safeRecipes = {} |
| 19 safer = safeRecipes | 19 safer = safeRecipes |
| 20 RecipeProfit.db = db; | 20 RecipeProfit.db = db; |
| 21 | |
| 22 local function deepcopy(object) | |
| 23 local lookup_table = {} | |
| 24 local function _copy(object) | |
| 25 if type(object) ~= "table" then | |
| 26 return object | |
| 27 elseif lookup_table[object] then | |
| 28 return lookup_table[object] | |
| 29 end | |
| 30 local new_table = {} | |
| 31 lookup_table[object] = new_table | |
| 32 for index, value in pairs(object) do | |
| 33 new_table[_copy(index)] = _copy(value) | |
| 34 end | |
| 35 return setmetatable(new_table, getmetatable(object)) | |
| 36 end | |
| 37 return _copy(object) | |
| 38 end | |
| 39 | 21 |
| 40 function debugprint(val, indent) | 22 function debugprint(val, indent) |
| 41 indent = indent or ""; | 23 indent = indent or ""; |
| 42 if not(type(val) == "table") then | 24 if not(type(val) == "table") then |
| 43 print("Not table: " .. val) | 25 print("Not table: " .. val) |
| 49 print(indent .. "table key: {") | 31 print(indent .. "table key: {") |
| 50 debugprint(k, indent .. " ") | 32 debugprint(k, indent .. " ") |
| 51 print(indent .. "} = {") | 33 print(indent .. "} = {") |
| 52 debugprint(v, indent .. " ") | 34 debugprint(v, indent .. " ") |
| 53 print(indent .. "}") | 35 print(indent .. "}") |
| 54 elseif(type(v) == "table") then | 36 elseif(type(v) == "table") then |
| 55 print(indent .. k .. " = {") | 37 print(indent .. k .. " = {") |
| 56 debugprint(v, indent .. " ") | 38 debugprint(v, indent .. " ") |
| 57 print(indent .. "}") | 39 print(indent .. "}") |
| 58 else | 40 else |
| 59 print(indent .. k .. " = " .. v) | 41 if(type(v) ~= "boolean") then |
| 42 print(indent .. k .. " = " .. v) | |
| 43 else | |
| 44 print(indent .. k .. " = " .. (v and "true" or "false")) | |
| 45 end | |
| 60 end | 46 end |
| 61 end | 47 end |
| 62 end | 48 end |
| 63 | 49 |
| 64 local defaultProfile = { | 50 local defaultProfile = { |
| 153 | 139 |
| 154 for k, v in pairs(defaults) do | 140 for k, v in pairs(defaults) do |
| 155 profile[k] = profile[k] or v; | 141 profile[k] = profile[k] or v; |
| 156 end | 142 end |
| 157 | 143 |
| 144 self:RegisterChatCommand("recipeprofit", "ShowOptions") | |
| 145 self:RegisterChatCommand("rp", "ShowOptions") | |
| 146 self:RegisterChatCommand("profit", "ShowOptions") | |
| 147 | |
| 158 db.profile = profile | 148 db.profile = profile |
| 159 db.storage = {} | 149 db.storage = {} |
| 160 | 150 |
| 161 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options) | 151 GatherMate:GetModule("Config"):RegisterModule("RecipeProfit", options) |
| 162 GatherMate:RegisterDBType("RecipeProfit", db.storage) | 152 GatherMate:RegisterDBType("RecipeProfit", db.storage) |
| 201 arg = "RecipeProfit", | 191 arg = "RecipeProfit", |
| 202 } | 192 } |
| 203 | 193 |
| 204 GatherMate:GetModule("Config"):UpdateConfig() | 194 GatherMate:GetModule("Config"):UpdateConfig() |
| 205 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") | 195 GatherMate:GetModule("Config"):SendMessage("GatherMateConfigChanged") |
| 196 end | |
| 197 | |
| 198 function RecipeProfit:ShowOptions() | |
| 199 LibStub("AceConfigDialog-3.0"):Open("GatherMate", nil, "RecipeProfit") | |
| 206 end | 200 end |
| 207 | 201 |
| 208 function button_update(self) | 202 function button_update(self) |
| 209 local buttonName = _G[self:GetName().."Name"]; | 203 local buttonName = _G[self:GetName().."Name"]; |
| 210 local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID()); | 204 local link = GetMerchantItemLink(_G[self:GetName().."ItemButton"]:GetID()); |
| 230 end | 224 end |
| 231 end | 225 end |
| 232 | 226 |
| 233 function RecipeProfit:UpdateButtons(event) | 227 function RecipeProfit:UpdateButtons(event) |
| 234 --print("UpdateButtons", event) | 228 --print("UpdateButtons", event) |
| 229 if(not MerchantFrame:IsVisible()) then | |
| 230 --print("UpdateButtons - (Event: ", event, ") - MerchantFrame not visible."); | |
| 231 return; | |
| 232 end | |
| 233 | |
| 235 for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do | 234 for i=1, MERCHANT_ITEMS_PER_PAGE, 1 do |
| 236 local buttonframe = _G["MerchantItem"..i]; | 235 local buttonframe = _G["MerchantItem"..i]; |
| 237 local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i); | 236 local index = (((MerchantFrame.page - 1) * MERCHANT_ITEMS_PER_PAGE) + i); |
| 238 --print(index) | 237 --print(index) |
| 239 if index <= GetMerchantNumItems() then | 238 if index <= GetMerchantNumItems() then |
| 240 button_update(buttonframe) | 239 button_update(buttonframe) |
| 241 else | 240 --[[else |
| 242 --print(i, index, GetMerchantNumItems()) | 241 --print(i, index, GetMerchantNumItems()) |
| 243 local itemButton = _G["MerchantItem"..i.."ItemButton"]; | 242 local itemButton = _G["MerchantItem"..i.."ItemButton"]; |
| 244 local merchantButton = _G["MerchantItem"..i]; | 243 local merchantButton = _G["MerchantItem"..i]; |
| 245 itemButton.price = nil; | 244 itemButton.price = nil; |
| 246 itemButton.hasItem = nil; | 245 itemButton.hasItem = nil; |
| 248 SetItemButtonNameFrameVertexColor(merchantButton, 0.5, 0.5, 0.5); | 247 SetItemButtonNameFrameVertexColor(merchantButton, 0.5, 0.5, 0.5); |
| 249 SetItemButtonSlotVertexColor(merchantButton,0.4, 0.4, 0.4); | 248 SetItemButtonSlotVertexColor(merchantButton,0.4, 0.4, 0.4); |
| 250 _G["MerchantItem"..i.."Name"]:SetText(""); | 249 _G["MerchantItem"..i.."Name"]:SetText(""); |
| 251 _G["MerchantItem"..i.."MoneyFrame"]:Hide(); | 250 _G["MerchantItem"..i.."MoneyFrame"]:Hide(); |
| 252 _G["MerchantItem"..i.."AltCurrencyFrame"]:Hide(); | 251 _G["MerchantItem"..i.."AltCurrencyFrame"]:Hide(); |
| 252 ]] | |
| 253 end | 253 end |
| 254 end | 254 end |
| 255 end | 255 end |
| 256 | 256 |
| 257 | 257 |
| 260 _G["MerchantPrevPageButton"]:HookScript("OnClick", self.UpdateButtons) | 260 _G["MerchantPrevPageButton"]:HookScript("OnClick", self.UpdateButtons) |
| 261 _G["MerchantNextPageButton"]:HookScript("OnClick", self.UpdateButtons) | 261 _G["MerchantNextPageButton"]:HookScript("OnClick", self.UpdateButtons) |
| 262 | 262 |
| 263 self:RegisterEvent("MERCHANT_SHOW", "UpdateButtons") | 263 self:RegisterEvent("MERCHANT_SHOW", "UpdateButtons") |
| 264 self:RegisterEvent("MERCHANT_UPDATE", "UpdateButtons") | 264 self:RegisterEvent("MERCHANT_UPDATE", "UpdateButtons") |
| 265 self:RegisterEvent("BAG_UPDATE", "UpdateButtons") | |
| 265 | 266 |
| 266 RecipeProfit:DoMerge() | 267 RecipeProfit:DoMerge() |
| 267 end | 268 end |
| 268 | 269 |
| 269 local ids = {} | 270 local ids = {} |
