Fixed "click scan again to close" for Smelting (damnable kludge...fixes ticket #1029) and cleaned up some code in the process.
James D. Callahan III [07-07-10 - 14:54]
Fixed "click scan again to close" for Smelting (damnable kludge...fixes ticket #1029) and cleaned up some code in the process.
diff --git a/ARL.lua b/ARL.lua
index b3c1481..8522c39 100644
--- a/ARL.lua
+++ b/ARL.lua
@@ -426,33 +426,21 @@ function addon:OnInitialize()
scan_button:RegisterForClicks("LeftButtonUp")
scan_button:SetScript("OnClick",
function(self, button, down)
- local cprof = GetTradeSkillLine()
- local current_prof = private.ordered_professions[addon.Frame.profession]
-
- if addon.Frame:IsVisible() then
- if IsShiftKeyDown() and not IsAltKeyDown() and not IsControlKeyDown() then
- -- Shift only (Text dump)
- addon:Scan(true)
- elseif not IsShiftKeyDown() and IsAltKeyDown() and not IsControlKeyDown() then
- -- Alt only (Wipe icons from map)
- addon:ClearMap()
- elseif not IsShiftKeyDown() and not IsAltKeyDown() and not IsControlKeyDown() and current_prof == cprof then
- -- If we have the same profession open, then we close the scanned window
+ local cur_profession = GetTradeSkillLine()
+ local prev_profession = addon.Frame.prof_name or private.ordered_professions[addon.Frame.profession]
+
+ local shift_key = _G.IsShiftKeyDown()
+ local alt_key = _G.IsAltKeyDown()
+ local ctrl_key = _G.IsControlKeyDown()
+
+ if shift_key and not alt_key and not ctrl_key then
+ addon:Scan(true)
+ elseif not shift_key and alt_key and not ctrl_key then
+ addon:ClearWaypoints()
+ elseif not shift_key and not alt_key and not ctrl_key then
+ if addon.Frame:IsVisible() and prev_profession == cur_profession then
addon.Frame:Hide()
- elseif not IsShiftKeyDown() and not IsAltKeyDown() and not IsControlKeyDown() then
- -- If we have a different profession open we do a scan
- addon:Scan(false)
- addon:AddWaypoint()
- end
- else
- if IsShiftKeyDown() and not IsAltKeyDown() and not IsControlKeyDown() then
- -- Shift only (Text dump)
- addon:Scan(true)
- elseif not IsShiftKeyDown() and IsAltKeyDown() and not IsControlKeyDown() then
- -- Alt only (Wipe icons from map)
- addon:ClearMap()
- elseif not IsShiftKeyDown() and not IsAltKeyDown() and not IsControlKeyDown() then
- -- No modification
+ else
addon:Scan(false)
addon:AddWaypoint()
end
@@ -511,7 +499,7 @@ function addon:OnInitialize()
return
end
local recipe_list = private.recipe_list
- local shifted = IsShiftKeyDown()
+ local shifted = _G.IsShiftKeyDown()
local count = 0
for spell_id in pairs(unit.item_list) do
diff --git a/Config.lua b/Config.lua
index 0cc7f51..2a978af 100644
--- a/Config.lua
+++ b/Config.lua
@@ -327,7 +327,9 @@ local function giveMap()
name = L["Clear Waypoints"],
disabled = not has_waypoints,
desc = L["CLEAR_WAYPOINTS_DESC"],
- func = function() addon:ClearMap() end,
+ func = function()
+ addon:ClearWaypoints()
+ end,
},
},
}
diff --git a/Waypoint.lua b/Waypoint.lua
index 8558faa..2a0cbb5 100644
--- a/Waypoint.lua
+++ b/Waypoint.lua
@@ -306,7 +306,7 @@ local INSTANCE_LOCATIONS = {
local iconlist = {}
-- Clears all the icons from the world map and the mini-map
-function addon:ClearMap()
+function addon:ClearWaypoints()
if _G.TomTom and _G.TomTom.RemoveWaypoint then
while iconlist[1] do
_G.TomTom:RemoveWaypoint(table.remove(iconlist))