From 87879e97d48f53b83c518a6e551fd86b81426799 Mon Sep 17 00:00:00 2001 From: Jim-Bim Date: Sat, 17 Jan 2009 19:48:05 +0000 Subject: [PATCH] AckisRecipeList: - added reverse profession switching (rightclick on icon) --- ARLFrame.lua | 77 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/ARLFrame.lua b/ARLFrame.lua index fdbd17a..d3616b8 100644 --- a/ARLFrame.lua +++ b/ARLFrame.lua @@ -1944,7 +1944,7 @@ end -- Output: -- Switch the displayed profession in the main panel -function addon.SwitchProfs() +function addon.SwitchProfs(button) -- Known professions should be in playerData["Professions"] -- This loop is gonna be weird. The reason is because we need to @@ -1961,27 +1961,55 @@ function addon.SwitchProfs() -- ok, so first off, if we've never done this before, there is no "current" -- and a single iteration will do nicely, thank you - if (currentProfIndex == 0) then - startLoop = 1 - endLoop = addon.MaxProfessions + 1 - else - startLoop = currentProfIndex + 1 - endLoop = currentProfIndex - end - local index = startLoop - while (index ~= endLoop) do - if (index > MaxProfessions) then - index = 1 - else - if (playerData["Professions"][SortedProfessions[index].name] == true) then - displayProf = index - currentProfIndex = index - break - else - index = index + 1 - end - end - end + if button == "LeftButton" then + -- normal profession switch + if (currentProfIndex == 0) then + startLoop = 1 + endLoop = addon.MaxProfessions + 1 + else + startLoop = currentProfIndex + 1 + endLoop = currentProfIndex + end + local index = startLoop + + while (index ~= endLoop) do + if (index > MaxProfessions) then + index = 1 + else + if (playerData["Professions"][SortedProfessions[index].name] == true) then + displayProf = index + currentProfIndex = index + break + else + index = index + 1 + end + end + end + else + -- reverse profession switch + if (currentProfIndex == 0) then + startLoop = addon.MaxProfessions + 1 + endLoop = 0 + else + startLoop = currentProfIndex - 1 + endLoop = currentProfIndex + end + local index = startLoop + + while (index ~= endLoop) do + if (index < 1) then + index = MaxProfessions + else + if (playerData["Professions"][SortedProfessions[index].name] == true) then + displayProf = index + currentProfIndex = index + break + else + index = index - 1 + end + end + end + end -- Redisplay the button with the new skill SetSwitcherTexture(SortedProfessions[currentProfIndex].texture) playerData.playerProfession = SortedProfessions[currentProfIndex].name @@ -3304,9 +3332,10 @@ function addon:CreateFrame( ARL_SwitcherButton:SetWidth(64) ARL_SwitcherButton:SetHeight(64) ARL_SwitcherButton:SetPoint("TOPLEFT", addon.Frame, "TOPLEFT", 1, -2) + ARL_SwitcherButton:RegisterForClicks("LeftButtonUp", "RightButtonUp") ARL_SwitcherButton:SetScript("OnClick", - function() - addon.SwitchProfs(cPlayer) + function(self, button) + addon.SwitchProfs(button) end ) -- 1.7.9.5