Mercurial > wow > wowdb-profiler
comparison Main.lua @ 479:cf08b2748711
Removed backwards compatibility for Patch 6.2.4 in order to simplify code, now that Patch 7.0.3 is on Live realms.
author | Caleb Atherton <catherton@curse.com> |
---|---|
date | Wed, 03 Aug 2016 12:44:12 -0400 |
parents | 78147d7517fd |
children | 6f689ac680bd |
comparison
equal
deleted
inserted
replaced
478:8af940221d3a | 479:cf08b2748711 |
---|---|
251 function TradeSkillExecutePer(iter_func) | 251 function TradeSkillExecutePer(iter_func) |
252 if not _G.TradeSkillFrame or not _G.TradeSkillFrame:IsVisible() then | 252 if not _G.TradeSkillFrame or not _G.TradeSkillFrame:IsVisible() then |
253 return | 253 return |
254 end | 254 end |
255 | 255 |
256 if (private.isLegion) then | 256 local recipes = _G.C_TradeSkillUI.GetAllRecipeIDs() |
257 local recipes = _G.C_TradeSkillUI.GetAllRecipeIDs() | 257 |
258 | 258 if recipes and (#recipes > 0) then |
259 if recipes and (#recipes > 0) then | 259 for i = 1, #recipes do |
260 for i = 1, #recipes do | 260 if iter_func(_G.C_TradeSkillUI.GetRecipeInfo(recipes[i]).name, recipes[i]) then |
261 if iter_func(_G.C_TradeSkillUI.GetRecipeInfo(recipes[i]).name, recipes[i]) then | |
262 break | |
263 end | |
264 end | |
265 end | |
266 else | |
267 -- Clear the search box focus so the scan will have correct results. | |
268 local search_box = _G.TradeSkillFrameSearchBox | |
269 search_box:SetText("") | |
270 | |
271 _G.TradeSkillSearch_OnTextChanged(search_box) | |
272 search_box:ClearFocus() | |
273 search_box:GetScript("OnEditFocusLost")(search_box) | |
274 | |
275 table.wipe(header_list) | |
276 | |
277 -- Save the current state of the TradeSkillFrame so it can be restored after we muck with it. | |
278 local have_materials = _G.TradeSkillFrame.filterTbl.hasMaterials | |
279 local have_skillup = _G.TradeSkillFrame.filterTbl.hasSkillUp | |
280 | |
281 if have_materials then | |
282 _G.TradeSkillFrame.filterTbl.hasMaterials = false | |
283 _G.TradeSkillOnlyShowMakeable(false) | |
284 end | |
285 | |
286 if have_skillup then | |
287 _G.TradeSkillFrame.filterTbl.hasSkillUp = false | |
288 _G.TradeSkillOnlyShowSkillUps(false) | |
289 end | |
290 _G.SetTradeSkillInvSlotFilter(0, true, true) | |
291 _G.TradeSkillUpdateFilterBar() | |
292 _G.TradeSkillFrame_Update() | |
293 | |
294 -- Expand all headers so we can see all the recipes there are | |
295 for tradeskill_index = 1, _G.GetNumTradeSkills() do | |
296 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index) | |
297 | |
298 if tradeskill_type == "header" or tradeskill_type == "subheader" then | |
299 if not is_expanded then | |
300 header_list[name] = true | |
301 _G.ExpandTradeSkillSubClass(tradeskill_index) | |
302 end | |
303 elseif iter_func(name, tradeskill_index) then | |
304 break | 261 break |
305 end | 262 end |
306 end | 263 end |
307 | |
308 -- Restore the state of the things we changed. | |
309 for tradeskill_index = 1, _G.GetNumTradeSkills() do | |
310 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index) | |
311 | |
312 if header_list[name] then | |
313 _G.CollapseTradeSkillSubClass(tradeskill_index) | |
314 end | |
315 end | |
316 _G.TradeSkillFrame.filterTbl.hasMaterials = have_materials | |
317 _G.TradeSkillOnlyShowMakeable(have_materials) | |
318 _G.TradeSkillFrame.filterTbl.hasSkillUp = have_skillup | |
319 _G.TradeSkillOnlyShowSkillUps(have_skillup) | |
320 | |
321 _G.TradeSkillUpdateFilterBar() | |
322 _G.TradeSkillFrame_Update() | |
323 end | 264 end |
324 end | 265 end |
325 end -- do-block | 266 end -- do-block |
326 | 267 |
327 | 268 |
973 local instance_difficulty_id = tonumber(item_results[13]) or 0 | 914 local instance_difficulty_id = tonumber(item_results[13]) or 0 |
974 local num_bonus_ids = tonumber(item_results[14]) or 0 | 915 local num_bonus_ids = tonumber(item_results[14]) or 0 |
975 -- upgrade_value is optional in 6.2! can be detected using upgrade_type_id, but it's just as easy to check like this | 916 -- upgrade_value is optional in 6.2! can be detected using upgrade_type_id, but it's just as easy to check like this |
976 local upgrade_value = tonumber(item_results[15 + num_bonus_ids]) or 0 | 917 local upgrade_value = tonumber(item_results[15 + num_bonus_ids]) or 0 |
977 | 918 |
978 -- LEGION | 919 local unkItemField1 = tonumber(item_results[16 + num_bonus_ids]) or 0 |
979 if private.isLegion then | 920 local unkItemField2 = tonumber(item_results[17 + num_bonus_ids]) or 0 |
980 local unkItemField1 = tonumber(item_results[16 + num_bonus_ids]) or 0 | 921 if unkItemField1 > 0 then Debug("unkItemField1 is non-zero, specifically %d.", unkItemField1) end |
981 local unkItemField2 = tonumber(item_results[17 + num_bonus_ids]) or 0 | 922 if unkItemField2 > 0 then Debug("unkItemField2 is non-zero, specifically %d.", unkItemField2) end |
982 if unkItemField1 > 0 then Debug("unkItemField1 is non-zero, specifically %d.", unkItemField1) end | |
983 if unkItemField2 > 0 then Debug("unkItemField2 is non-zero, specifically %d.", unkItemField2) end | |
984 end | |
985 | 923 |
986 -- If there is anything special (non-zero) for this item then we need to make note of everything | 924 -- If there is anything special (non-zero) for this item then we need to make note of everything |
987 if math.max(suffix_id, instance_difficulty_id, num_bonus_ids, upgrade_value) ~= 0 then | 925 if math.max(suffix_id, instance_difficulty_id, num_bonus_ids, upgrade_value) ~= 0 then |
988 item = DBEntry("items", item_id) | 926 item = DBEntry("items", item_id) |
989 item.suffix_id = suffix_id | 927 item.suffix_id = suffix_id |
1140 | 1078 |
1141 do | 1079 do |
1142 local COORD_MAX = 5 | 1080 local COORD_MAX = 5 |
1143 | 1081 |
1144 function WDP:UpdateTargetLocation() | 1082 function WDP:UpdateTargetLocation() |
1145 -- LEGION supported here | 1083 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or not _G.UnitIsDead("target") or _G.UnitIsTapDenied("target") then |
1146 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or not _G.UnitIsDead("target") then | |
1147 return | 1084 return |
1148 end | 1085 end |
1149 | 1086 |
1150 for index = 1, 4 do | 1087 for index = 1, 4 do |
1151 if not _G.CheckInteractDistance("target", index) then | 1088 if not _G.CheckInteractDistance("target", index) then |
1599 local RECIPE_MATCH = _G.ERR_LEARN_RECIPE_S:gsub("%%s", "(.*)") | 1536 local RECIPE_MATCH = _G.ERR_LEARN_RECIPE_S:gsub("%%s", "(.*)") |
1600 | 1537 |
1601 | 1538 |
1602 local function RecordDiscovery(tradeskill_name, tradeskill_index) | 1539 local function RecordDiscovery(tradeskill_name, tradeskill_index) |
1603 if tradeskill_name == private.discovered_recipe_name then | 1540 if tradeskill_name == private.discovered_recipe_name then |
1604 if (private.isLegion) then | 1541 DBEntry("spells", tonumber(_G.C_TradeSkillUI.GetRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))).discovery = ("%d:%d"):format(private.previous_spell_id, private.profession_level) |
1605 DBEntry("spells", tonumber(_G.C_TradeSkillUI.GetRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))).discovery = ("%d:%d"):format(private.previous_spell_id, private.profession_level) | |
1606 else | |
1607 DBEntry("spells", tonumber(_G.GetTradeSkillRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))).discovery = ("%d:%d"):format(private.previous_spell_id, private.profession_level) | |
1608 end | |
1609 | 1542 |
1610 private.discovered_recipe_name = nil | 1543 private.discovered_recipe_name = nil |
1611 private.profession_level = nil | 1544 private.profession_level = nil |
1612 private.previous_spell_id = nil | 1545 private.previous_spell_id = nil |
1613 | 1546 |
1632 if not item_id then | 1565 if not item_id then |
1633 if not private.trainer_shown then | 1566 if not private.trainer_shown then |
1634 local recipe_name = message:match(RECIPE_MATCH) | 1567 local recipe_name = message:match(RECIPE_MATCH) |
1635 | 1568 |
1636 if recipe_name and private.previous_spell_id then | 1569 if recipe_name and private.previous_spell_id then |
1637 local profession_name, prof_level | 1570 local profession_name, prof_level = _G.C_TradeSkillUI.GetTradeSkillLine() |
1638 if private.isLegion then | |
1639 profession_name, prof_level= _G.C_TradeSkillUI.GetTradeSkillLine() | |
1640 else | |
1641 profession_name, prof_level= _G.GetTradeSkillLine() | |
1642 end | |
1643 | 1571 |
1644 if profession_name == _G.UNKNOWN then | 1572 if profession_name == _G.UNKNOWN then |
1645 return | 1573 return |
1646 end | 1574 end |
1647 private.discovered_recipe_name = recipe_name | 1575 private.discovered_recipe_name = recipe_name |
2584 Forge = forge_spell_ids, | 2512 Forge = forge_spell_ids, |
2585 } | 2513 } |
2586 | 2514 |
2587 | 2515 |
2588 local function RegisterTools(tradeskill_name, tradeskill_index) | 2516 local function RegisterTools(tradeskill_name, tradeskill_index) |
2589 local link | 2517 local link = _G.C_TradeSkillUI.GetRecipeLink(tradeskill_index) |
2590 if (private.isLegion) then | |
2591 link = _G.C_TradeSkillUI.GetRecipeLink(tradeskill_index) | |
2592 else | |
2593 link = _G.GetTradeSkillRecipeLink(tradeskill_index) | |
2594 end | |
2595 | 2518 |
2596 if link then | 2519 if link then |
2597 local spell_id = tonumber(link:match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)")) | 2520 local spell_id = tonumber(link:match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)")) |
2598 local required_tool | 2521 local required_tool = _G.C_TradeSkillUI.GetRecipeTools(tradeskill_index) |
2599 if (private.isLegion) then | |
2600 required_tool = _G.C_TradeSkillUI.GetRecipeTools(tradeskill_index) | |
2601 else | |
2602 required_tool = _G.GetTradeSkillTools(tradeskill_index) | |
2603 end | |
2604 | 2522 |
2605 if required_tool then | 2523 if required_tool then |
2606 for tool_name, registry in pairs(TRADESKILL_TOOLS) do | 2524 for tool_name, registry in pairs(TRADESKILL_TOOLS) do |
2607 if required_tool:find(tool_name) then | 2525 if required_tool:find(tool_name) then |
2608 registry[spell_id] = true | 2526 registry[spell_id] = true |
2612 end | 2530 end |
2613 end | 2531 end |
2614 | 2532 |
2615 | 2533 |
2616 function WDP:TRADE_SKILL_SHOW(event_name) | 2534 function WDP:TRADE_SKILL_SHOW(event_name) |
2617 local profession_name, prof_level | 2535 local profession_name, prof_level = _G.C_TradeSkillUI.GetTradeSkillLine() |
2618 if private.isLegion then | |
2619 profession_name, prof_level= _G.C_TradeSkillUI.GetTradeSkillLine() | |
2620 else | |
2621 profession_name, prof_level= _G.GetTradeSkillLine() | |
2622 end | |
2623 | 2536 |
2624 if profession_name == _G.UNKNOWN then | 2537 if profession_name == _G.UNKNOWN then |
2625 return | 2538 return |
2626 end | 2539 end |
2627 TradeSkillExecutePer(RegisterTools) | 2540 TradeSkillExecutePer(RegisterTools) |