Quantcast

Fixed UIButtons lua error

Repooc [10-26-14 - 23:34]
Fixed UIButtons lua error
Filename
CHANGELOG.txt
ElvUI_SLE/modules/uibuttons.lua
ElvUI_SLE/options/uibuttons_c.lua
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 08f2880..d25de7b 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,6 @@
+v2.07
+- Fixed UIButtons lua error for mouse over + combat
+
 v2.06 10/25/2014
 - Update Ace Libs
 - Remove RealmInfo Libs
diff --git a/ElvUI_SLE/modules/uibuttons.lua b/ElvUI_SLE/modules/uibuttons.lua
index a542efd..7d39c63 100644
--- a/ElvUI_SLE/modules/uibuttons.lua
+++ b/ElvUI_SLE/modules/uibuttons.lua
@@ -2,8 +2,34 @@ local E, L, V, P, G = unpack(ElvUI);
 local UB = E:GetModule('SLE_UIButtons');
 local Btemplate = "SecureActionButtonTemplate"
 local NumBut = 5
+local BorderColor = E['media'].bordercolor
+
+local function OnEnter(self)
+	UIBFrame:SetAlpha(1)
+end
+
+local function OnLeave(self)
+	if E.db.sle.uibuttons.mouse then
+		UIBFrame:SetAlpha(0)
+	end
+end
+
+function UB:UpdateMouseOverSetting()
+	if E.db.sle.uibuttons.mouse then
+		UIBFrame:SetAlpha(0)
+	else
+		UIBFrame:SetAlpha(1)
+	end
+end

 local UIBFrame = CreateFrame('Frame', "UIBFrame", E.UIParent);
+UIBFrame:SetFrameLevel(5);
+UIBFrame:SetFrameStrata('BACKGROUND');
+UIBFrame:Point("LEFT", E.UIParent, "LEFT", -2, 0);
+UIBFrame:SetClampedToScreen(true)
+UIBFrame:HookScript('OnEnter', OnEnter)
+UIBFrame:HookScript('OnLeave', OnLeave)
+
 local Cbutton = CreateFrame("Button", "ConfigUIButton", UIBFrame, Btemplate)
 local Rbutton = CreateFrame("Button", "ReloadUIButton", UIBFrame, Btemplate)
 local Mbutton = CreateFrame("Button", "MoveUIButton", UIBFrame, Btemplate)
@@ -11,7 +37,7 @@ local Bbutton = CreateFrame("Button", "Bbutton", UIBFrame, Btemplate)
 local Abutton = CreateFrame("Button", "Abutton", UIBFrame, Btemplate)

 if IsAddOnLoaded("iFilger_ConfigUI") then
-	local Fbutton = CreateFrame("Button", "Fbutton", UIBFrame, Btemplate)
+	local Fbutton = CreateFrame("Button", "Fbutton", UIBFrame)
 	NumBut = 6
 end

@@ -23,29 +49,6 @@ local ButtonTable = {
 	Abutton,
 }

-local function Mouseover()
-	local self = UIBFrame
-	if E.db.sle.uibuttons.mouse then
-		if (MouseIsOver(self)) then
-			UIFrameFadeIn(self, 0.2, self:GetAlpha(), 1)
-		else
-			UIFrameFadeOut(self, 0.2, self:GetAlpha(), 0)
-		end
-	else
-		UIBFrame:SetAlpha(1)
-	end
-end
-
-local function CreateHolder()
-	UIBFrame:SetFrameLevel(5);
-	UIBFrame:SetFrameStrata('BACKGROUND');
-	UIBFrame:Point("LEFT", E.UIParent, "LEFT", -2, 0);
-
-	UIBFrame:SetScript("OnUpdate", function(self,event,...)
-		Mouseover()
-	end)
-end
-
 local function CreateB(button, symbol, text, name, desc)
 	button:CreateBackdrop()
 	local button_text = button:CreateFontString(nil, 'OVERLAY')
@@ -86,6 +89,8 @@ local function CreateB(button, symbol, text, name, desc)
 	button:SetScript("OnLeave", function(self)
 		GameTooltip:Hide()
 	end)
+	button:HookScript('OnEnter', OnEnter)
+	button:HookScript('OnLeave', OnLeave)
 end

 local function CreateButtons()
@@ -140,7 +145,7 @@ local function MoverSize()
 	end
 end

-local function FrameSize()
+function UB:FrameSize()
 	local db = E.db.sle.uibuttons
 	MoverSize()

@@ -154,24 +159,19 @@ local function FrameSize()
 	Positioning()
 end

-function UB:Start()
-	if E.db.sle.uibuttons.enable then
-		UIBFrame:Show()
-	else
+function UB:Toggle()
+	if not E.db.sle.uibuttons.enable then
 		UIBFrame:Hide()
+	else
+		UIBFrame:Show()
+		UB:UpdateMouseOverSetting()
 	end
 end

-function UB:UpdateAll()
-	FrameSize()
-	UB:Start()
-end
-
 function UB:Initialize()
-	CreateHolder()
-	FrameSize()
+	UB:FrameSize()
 	CreateButtons()
-	UB:Start()
+	UB:Toggle()

 	E.FrameLocks['UIBFrame'] = true

diff --git a/ElvUI_SLE/options/uibuttons_c.lua b/ElvUI_SLE/options/uibuttons_c.lua
index b8ecfbc..2b7a9ab 100644
--- a/ElvUI_SLE/options/uibuttons_c.lua
+++ b/ElvUI_SLE/options/uibuttons_c.lua
@@ -23,7 +23,7 @@ local function configTable()
 				name = L["Enable"],
 				desc = L["Show/Hide UI buttons."],
 				get = function(info) return E.db.sle.uibuttons.enable end,
-				set = function(info, value) E.db.sle.uibuttons.enable = value; UB:Start() end
+				set = function(info, value) E.db.sle.uibuttons.enable = value; UB:Toggle() end
 			},
 			space1 = {
 				order = 4,
@@ -43,7 +43,7 @@ local function configTable()
 				min = 12, max = 25, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.size end,
-				set = function(info, value) E.db.sle.uibuttons.size = value; UB:UpdateAll() end,
+				set = function(info, value) E.db.sle.uibuttons.size = value; UB:FrameSize() end,
 			},
 			spacing = {
 				order = 7,
@@ -53,7 +53,7 @@ local function configTable()
 				min = 1, max = 10, step = 1,
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.spacing end,
-				set = function(info, value) E.db.sle.uibuttons.spacing = value; UB:UpdateAll() end,
+				set = function(info, value) E.db.sle.uibuttons.spacing = value; UB:FrameSize() end,
 			},
 			mouse = {
 				order = 8,
@@ -62,7 +62,7 @@ local function configTable()
 				desc = L["Show on mouse over."],
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.mouse end,
-				set = function(info, value) E.db.sle.uibuttons.mouse = value; end
+				set = function(info, value) E.db.sle.uibuttons.mouse = value; UB:UpdateMouseOverSetting() end
 			},
 			position = {
 				order = 10,
@@ -75,7 +75,7 @@ local function configTable()
 				},
 				disabled = function() return not E.db.sle.uibuttons.enable end,
 				get = function(info) return E.db.sle.uibuttons.position end,
-				set = function(info, value) E.db.sle.uibuttons.position = value; UB:UpdateAll() end,
+				set = function(info, value) E.db.sle.uibuttons.position = value; UB:FrameSize() end,
 			},
 		},
 	}