Quantcast

Updated for TukUI and IsAddonLoaded

Xruptor [12-24-15 - 17:36]
Updated for TukUI and IsAddonLoaded

-Updated the TOC
-Changed the way how addons are detected.
-Added IsAddonLoaded() to be a bit more efficient
-Added support for TukUI.
Filename
.gitignore
RightClickSelfCast.lua
RightClickSelfCast.toc
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d8fe4fa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/.project
diff --git a/RightClickSelfCast.lua b/RightClickSelfCast.lua
index 0425c7c..2148d13 100644
--- a/RightClickSelfCast.lua
+++ b/RightClickSelfCast.lua
@@ -1,78 +1,95 @@
---This mod makes every actionbutton of the blizzard actionbars right-click to be self-casting regardless of target.
-
-local bars = {
-"MainMenuBarArtFrame",
-"MultiBarBottomLeft",
-"MultiBarBottomRight",
-"MultiBarRight",
-"MultiBarLeft",
---"BonusActionBarFrame",
---"ShapeshiftBarFrame",
-"PossessBarFrame",
-}
-
-local f = CreateFrame("frame","RightClickSelfCast",UIParent)
-f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
-
-function f:PLAYER_REGEN_ENABLED()
-	self:PLAYER_LOGIN()
-	self:UnregisterEvent("PLAYER_REGEN_ENABLED")
-	self.PLAYER_REGEN_ENABLED = nil
-end
-
-function f:PLAYER_LOGIN()
-
-	-- if we load/reload in combat don't try to set secure attributes or we get action_blocked errors
-	if InCombatLockdown() or UnitAffectingCombat("player") then
-		self:RegisterEvent("PLAYER_REGEN_ENABLED")
-		return
-	end
-
-	-- Blizzard bars
-	for i, v in ipairs(bars) do
-		local bar = _G[v]
-		if bar ~= nil then
-			bar:SetAttribute("unit2", "player")
-		end
-	end
-
-	-- this is for the mod ExtraBar (Author: Cowmonster)
-	-- http://www.wowinterface.com/downloads/info14492-ExtraBar.html
-	for id=1, 12 do
-		local button = _G["ExtraBarButton"..id]
-		if button ~= nil then
-			button:SetAttribute("unit2", "player")
-		end
-	end
-
-	-- this is for the mod ExtraBars (Author: Alternator)
-	-- http://www.wowinterface.com/downloads/info13335-ExtraBars.html
-	for id=1, 4 do
-		local frame = _G["ExtraBar"..id]
-		if frame ~= nil then
-			frame:SetAttribute("unit2", "player")
-			for bid=1, 12 do
-				local button = _G["ExtraBar"..id.."Button"..bid]
-				if button ~= nil then
-					button:SetAttribute("unit2", "player")
-				end
-			end
-		end
-	end
-
-	-- ElvUI 3.05+ (Author: Elv22, TukUI fork)
-	-- http://www.wowinterface.com/downloads/info17749-ElvUI.html
-	local barID = 1
-	while _G["ElvUI_Bar"..barID] do
-		for	_,button in next,_G["ElvUI_Bar"..barID].buttons,nil do
-			button:SetAttribute("unit2", "player")
-		end
-		barID = barID+1
-	end
-
-	self:UnregisterEvent("PLAYER_LOGIN")
-	self.PLAYER_LOGIN = nil
-
-end
-
-if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end
+--This mod makes every actionbutton of the blizzard actionbars right-click to be self-casting regardless of target.
+
+local bars = {
+"MainMenuBarArtFrame",
+"MultiBarBottomLeft",
+"MultiBarBottomRight",
+"MultiBarRight",
+"MultiBarLeft",
+--"BonusActionBarFrame",
+--"ShapeshiftBarFrame",
+"PossessBarFrame",
+}
+
+local f = CreateFrame("frame","RightClickSelfCast",UIParent)
+f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
+
+function f:PLAYER_REGEN_ENABLED()
+	self:PLAYER_LOGIN()
+	self:UnregisterEvent("PLAYER_REGEN_ENABLED")
+	self.PLAYER_REGEN_ENABLED = nil
+end
+
+function f:PLAYER_LOGIN()
+
+	-- if we load/reload in combat don't try to set secure attributes or we get action_blocked errors
+	if InCombatLockdown() or UnitAffectingCombat("player") then
+		self:RegisterEvent("PLAYER_REGEN_ENABLED")
+		return
+	end
+
+	-- Blizzard bars
+	for i, v in ipairs(bars) do
+		local bar = _G[v]
+		if bar ~= nil then
+			bar:SetAttribute("unit2", "player")
+		end
+	end
+
+	-- this is for the mod ExtraBar (Author: Cowmonster)
+	-- http://www.wowinterface.com/downloads/info14492-ExtraBar.html
+	if IsAddOnLoaded('ExtraBar') then
+		for id=1, 12 do
+			local button = _G["ExtraBarButton"..id]
+			if button ~= nil then
+				button:SetAttribute("unit2", "player")
+			end
+		end
+	end
+
+	-- this is for the mod ExtraBars (Author: Alternator)
+	-- http://www.wowinterface.com/downloads/info13335-ExtraBars.html
+	if IsAddOnLoaded('Extra Bars') then
+		for id=1, 4 do
+			local frame = _G["ExtraBar"..id]
+			if frame ~= nil then
+				frame:SetAttribute("unit2", "player")
+				for bid=1, 12 do
+					local button = _G["ExtraBar"..id.."Button"..bid]
+					if button ~= nil then
+						button:SetAttribute("unit2", "player")
+					end
+				end
+			end
+		end
+	end
+
+	-- ElvUI (Author: Elv22, TukUI fork)
+	-- https://www.tukui.org/about.php?ui=elvui
+	if IsAddOnLoaded('ElvUI') then
+		local barID = 1
+		while _G["ElvUI_Bar"..barID] do
+			for	_,button in next,_G["ElvUI_Bar"..barID].buttons,nil do
+				button:SetAttribute("unit2", "player")
+			end
+			barID = barID+1
+		end
+	end
+
+	-- Tukui (Author: Elv22, TukUI fork)
+	-- https://www.tukui.org
+	if IsAddOnLoaded('Tukui') then
+		for id=1, 12 do
+			local button = _G["ActionButton"..id]
+			if button ~= nil then
+				button:SetAttribute("unit2", "player")
+			end
+		end
+	end
+
+	self:UnregisterEvent("PLAYER_LOGIN")
+	self.PLAYER_LOGIN = nil
+
+end
+
+if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end
diff --git a/RightClickSelfCast.toc b/RightClickSelfCast.toc
index d89590d..743c3bb 100644
--- a/RightClickSelfCast.toc
+++ b/RightClickSelfCast.toc
@@ -1,7 +1,7 @@
-## Interface: 60000
-## Title: RightClickSelfCast
-## Author: Xruptor
-## Version:  2.4
-## Notes: Makes all the Blizzard actionbars always self-cast on right-click (regardless of current target)
-
+## Interface: 60200
+## Title: RightClickSelfCast
+## Author: Xruptor
+## Version:  2.5
+## Notes: Makes all the Blizzard actionbars always self-cast on right-click (regardless of current target)
+
 RightClickSelfCast.lua
\ No newline at end of file