Quantcast

Skinning of minimap buttons with some changes to coords.

Repooc [02-23-13 - 10:49]
Skinning of minimap buttons with some changes to coords.
Filename
ElvUI_SLE/config/profile.lua
ElvUI_SLE/config/sle_private.lua
ElvUI_SLE/locales/english.lua
ElvUI_SLE/modules/minimap/load_minimap.xml
ElvUI_SLE/modules/minimap/minimapicons.lua
ElvUI_SLE/modules/minimap/options.lua
diff --git a/ElvUI_SLE/config/profile.lua b/ElvUI_SLE/config/profile.lua
index 2d552b4..e75677f 100644
--- a/ElvUI_SLE/config/profile.lua
+++ b/ElvUI_SLE/config/profile.lua
@@ -157,6 +157,11 @@ P['sle'] = {
 		['coords'] = {
 			['display'] = "SHOW",
 		},
+		['buttons'] = {
+			['anchor'] = "NOANCHOR",
+			['size'] = 24,
+			['mouseover'] = false,
+		},
 	},

 	--Power text on classbars
diff --git a/ElvUI_SLE/config/sle_private.lua b/ElvUI_SLE/config/sle_private.lua
index 5c2814b..08eca71 100644
--- a/ElvUI_SLE/config/sle_private.lua
+++ b/ElvUI_SLE/config/sle_private.lua
@@ -52,4 +52,11 @@ V['sle'] = {
 		['instance'] = "NONE",
 		['pvp'] = "NONE",
 	},
+
+	--Minimap Moduel
+	['minimap'] = {
+		['buttons'] = {
+			['enable'] = true,
+		},
+	},
 }
diff --git a/ElvUI_SLE/locales/english.lua b/ElvUI_SLE/locales/english.lua
index c361f2a..9f4144b 100644
--- a/ElvUI_SLE/locales/english.lua
+++ b/ElvUI_SLE/locales/english.lua
@@ -165,6 +165,25 @@ L["Sets size of buttons"] = true --Also used in UI buttons
 L["Direction"] = true
 L["Change the direction of buttons growth from the skull marker"] = true

+--Minimap--
+L["Minimap"] = true
+L["Minimap Options"] = true
+L['MINIMAP_DESC'] = "These options effect various aspects of the minimap.  Some options may not work if you disable minimap in the General section of ElvUI config."
+L["Enable/Disable Minimap Coords"] = true
+L["Minimap Coordinates"] = true
+L['Coords Display'] = true
+L['Change settings for the display of the coordinates that are on the minimap.'] = true
+L['Hide'] = true
+L["Minimap Buttons"] = true
+L['Enable/Disable minimap button skinning.'] = true
+L['Anchor Setting'] = true
+L['Anchor mode for displaying the minimap buttons are skinned.'] = true
+L['Horizontal Bar'] = true
+L['Vertical Bar'] = true
+L['Button Size'] = true
+L['The size of the minimap buttons when not anchored to the minimap.'] = true
+L['Show minimap buttons on mouseover.'] = true
+
 --Raid Utility--
 L["Raid Utility"] = true

diff --git a/ElvUI_SLE/modules/minimap/load_minimap.xml b/ElvUI_SLE/modules/minimap/load_minimap.xml
index 4b25734..a1cd949 100644
--- a/ElvUI_SLE/modules/minimap/load_minimap.xml
+++ b/ElvUI_SLE/modules/minimap/load_minimap.xml
@@ -1,4 +1,5 @@
 <Ui xmlns="http://www.blizzard.com/wow/ui/">
 	<Script file='minimapcoords.lua'/>
+	<Script file='minimapicons.lua'/>
 	<Script file='options.lua'/>
 </Ui>
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/minimap/minimapicons.lua b/ElvUI_SLE/modules/minimap/minimapicons.lua
index e566808..82c59e7 100644
--- a/ElvUI_SLE/modules/minimap/minimapicons.lua
+++ b/ElvUI_SLE/modules/minimap/minimapicons.lua
@@ -1 +1,242 @@
-local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
\ No newline at end of file
+local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
+local SMB = E:NewModule('SquareMinimapButtons', 'AceHook-3.0', 'AceEvent-3.0');
+
+local sub, len, find = string.sub, string.len, string.find
+local ignoreButtons = {
+	"AsphyxiaUIMinimapHelpButton",
+	"AsphyxiaUIMinimapVersionButton",
+	"ElvConfigToggle",
+	"ElvUIConfigToggle",
+	"ElvUI_ConsolidatedBuffs",
+	"GameTimeframe",
+	"HelpOpenTicketButton",
+	"MMHolder",
+	"QueueStatusMinimapButton",
+	"TimeManagerClockButton",
+}
+local genericIgnores = {
+	"Archy",
+	"GatherMatePin",
+	"GatherNote",
+	"GuildInstance",
+	"HandyNotesPin",
+	"MinimMap",
+	"Spy_MapNoteList_mini",
+	"ZGVMarker",
+}
+local partialIgnores = {
+	"Node",
+	"Note",
+	"Pin",
+}
+local whiteList = {
+	"LibDBIcon",
+}
+local moveButtons = {}
+local mmbuttonsAnchor, minimapButtonBar
+
+local function OnEnter()
+	if not E.db.sle.minimap.buttons.mouseover then return end
+	UIFrameFadeIn(MinimapButtonBar, 0.2, MinimapButtonBar:GetAlpha(), 1)
+end
+
+local function OnLeave()
+	if not E.db.sle.minimap.buttons.mouseover then return end
+	UIFrameFadeOut(MinimapButtonBar, 0.2, MinimapButtonBar:GetAlpha(), 0)
+end
+
+function SMB:SkinButton(frame)
+	if frame == nil or frame:GetName() == nil or (frame:GetObjectType() ~= "Button") or not frame:IsVisible() then return end
+
+	local name = frame:GetName()
+	local validIcon = false
+
+	for i = 1, #whiteList do
+		if sub(name, 1, len(whiteList[i])) == whiteList[i] then validIcon = true break end
+	end
+
+	if not validIcon then
+		for i = 1, #ignoreButtons do
+			if name == ignoreButtons[i] then return end
+		end
+
+		for i = 1, #genericIgnores do
+			if sub(name, 1, len(genericIgnores[i])) == genericIgnores[i] then return end
+		end
+
+		for i = 1, #partialIgnores do
+			if find(name, partialIgnores[i]) ~= nil then return end
+		end
+	end
+
+	frame:SetPushedTexture(nil)
+	frame:SetHighlightTexture(nil)
+	frame:SetDisabledTexture(nil)
+	if name == "DBMMinimapButton" then frame:SetNormalTexture("Interface\\Icons\\INV_Helmet_87") end
+	if name == "SmartBuff_MiniMapButton" then frame:SetNormalTexture(select(3, GetSpellInfo(12051))) end
+
+	if not frame.isSkinned then
+		frame:HookScript('OnEnter', OnEnter)
+		frame:HookScript('OnLeave', OnLeave)
+		frame:HookScript('OnClick', SMB.UpdateLayout)
+
+		for i = 1, frame:GetNumRegions() do
+			local region = select(i, frame:GetRegions())
+			frame.original = {}
+			frame.original.Width, frame.original.Height = frame:GetSize()
+			frame.original.Point, frame.original.relativeTo, frame.original.relativePoint, frame.original.xOfs, frame.original.yOfs = frame:GetPoint()
+			frame.original.Parent = frame:GetParent()
+			frame.original.FrameStrata = frame:GetFrameStrata()
+			if frame:HasScript("OnDragStart") then
+				frame.original.DragStart = frame:GetScript("OnDragStart")
+			end
+			if frame:HasScript("OnDragEnd") then
+				frame.original.DragEnd = frame:GetScript("OnDragEnd")
+			end
+
+			if (region:GetObjectType() == "Texture") then
+				local texture = region:GetTexture()
+
+				if (texture and (texture:find("Border") or texture:find("Background") or texture:find("AlphaMask"))) then
+					region:SetTexture(nil)
+				else
+					region:ClearAllPoints()
+					region:Point("TOPLEFT", frame, "TOPLEFT", 2, -2)
+					region:Point("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 2)
+					region:SetTexCoord( 0.1, 0.9, 0.1, 0.9 )
+					region:SetDrawLayer( "ARTWORK" )
+					if (name == "PS_MinimapButton") then
+						region.SetPoint = function() end
+					end
+				end
+			end
+		end
+		frame:SetTemplate("Default")
+
+		tinsert(moveButtons, name)
+		frame.isSkinned = true
+	end
+end
+
+function SMB:UpdateLayout()
+	if not E.minimapbuttons then return end
+
+	minimapButtonBar:SetPoint("CENTER", mmbuttonsAnchor, "CENTER", 0, 0)
+	minimapButtonBar:Height(E.db.sle.minimap.buttons.size + 4)
+	minimapButtonBar:Width(E.db.sle.minimap.buttons.size + 4)
+
+	local lastFrame, anchor1, anchor2, offsetX, offsetY
+	for i = 1, #moveButtons do
+		local frame =	_G[moveButtons[i]]
+
+		if E.db.sle.minimap.buttons.anchor == 'NOANCHOR' then
+			frame:SetParent(frame.original.Parent)
+			if frame.original.DragStart then
+				frame:SetScript("OnDragStart", frame.original.DragStart)
+			end
+			if frame.original.DragEnd then
+				frame:SetScript("OnDragStop", frame.original.DragEnd)
+			end
+
+			frame:ClearAllPoints()
+			frame:SetSize(24, 24)
+			frame:SetPoint(frame.original.Point, frame.original.relativeTo, frame.original.relativePoint, frame.original.xOfs, frame.original.yOfs)
+			frame:SetFrameStrata(frame.original.FrameStrata)
+			frame:SetMovable(true)
+		else
+			frame:SetParent(minimapButtonBar)
+			frame:SetMovable(false)
+			frame:SetScript("OnDragStart", nil)
+			frame:SetScript("OnDragStop", nil)
+
+			frame:ClearAllPoints()
+			frame:SetFrameStrata("LOW")
+			frame:Size(E.db.sle.minimap.buttons.size)
+			if E.db.sle.minimap.buttons.anchor == 'HORIZONTAL' then
+				anchor1 = 'RIGHT'
+				anchor2 = 'LEFT'
+				offsetX = -2
+				offsetY = 0
+			else
+				anchor1 = 'TOP'
+				anchor2 = 'BOTTOM'
+				offsetX = 0
+				offsetY = -2
+			end
+
+			if not lastFrame then
+				frame:SetPoint(anchor1, minimapButtonBar, anchor1, offsetX, offsetY)
+			else
+				frame:SetPoint(anchor1, lastFrame, anchor2, offsetX, offsetY)
+			end
+		end
+		lastFrame = frame
+	end
+
+	if E.db.sle.minimap.buttons.anchor ~= 'NOANCHOR' then
+		if E.db.sle.minimap.buttons.anchor == "HORIZONTAL" then
+			minimapButtonBar:Width((E.db.sle.minimap.buttons.size * #moveButtons) + (2 * #moveButtons + 1) + 1)
+		else
+			minimapButtonBar:Height((E.db.sle.minimap.buttons.size * #moveButtons) + (2 * #moveButtons + 1) + 1)
+		end
+		mmbuttonsAnchor:SetSize(minimapButtonBar:GetSize())
+		minimapButtonBar:Show()
+	else
+		minimapButtonBar:Hide()
+	end
+end
+
+function SMB:ChangeMouseOverSetting()
+	if E.db.sle.minimap.buttons.mouseover then
+		minimapButtonBar:SetAlpha(0)
+	else
+		minimapButtonBar:SetAlpha(1)
+	end
+end
+
+function SMB:SkinMinimapButtons()
+	SMB:RegisterEvent("ADDON_LOADED", "DelaySkinning")
+
+	for i = 1, Minimap:GetNumChildren() do
+		self:SkinButton(select(i, Minimap:GetChildren()))
+	end
+	SMB:UpdateLayout()
+end
+
+function SMB:DelaySkinning()
+	SMB:UnregisterEvent("ADDON_LOADED")
+
+	E:Delay(20, SMB:SkinMinimapButtons())
+end
+
+function SMB:CreateMinimapButtonFrames()
+	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
+
+	mmbuttonsAnchor = CreateFrame("Frame", "MMButtonsAnchor", E.UIParent)
+	mmbuttonsAnchor:Point("TOPRIGHT", ElvConfigToggle, "BOTTOMRIGHT", -2, -2)
+	mmbuttonsAnchor:Size(200, 32)
+	mmbuttonsAnchor:SetFrameStrata("BACKGROUND")
+
+	E:CreateMover(mmbuttonsAnchor, "MMButtonsMover", L["Minimap Button Bar"], nil, nil, nil, "ALL,S&L,S&L MISC")
+
+	minimapButtonBar = CreateFrame("Frame", "MinimapButtonBar", UIParent)
+	minimapButtonBar:SetFrameStrata("BACKGROUND")
+	minimapButtonBar:SetTemplate("Transparent")
+	minimapButtonBar:CreateShadow()
+	minimapButtonBar:SetPoint("CENTER", mmbuttonsAnchor, "CENTER", 0, 0)
+	minimapButtonBar:SetScript("OnEnter", OnEnter)
+	minimapButtonBar:SetScript("OnLeave", OnLeave)
+
+	self:ChangeMouseOverSetting()
+	self:DelaySkinning()
+end
+
+function SMB:Initialize()
+	if not E.private.sle.minimap.buttons.enable then return end
+
+	E.minimapbuttons = SMB
+
+	self:RegisterEvent("PLAYER_ENTERING_WORLD", "CreateMinimapButtonFrames")
+end
+
+E:RegisterModule(SMB:GetName())
\ No newline at end of file
diff --git a/ElvUI_SLE/modules/minimap/options.lua b/ElvUI_SLE/modules/minimap/options.lua
index fee9c76..17e6fed 100644
--- a/ElvUI_SLE/modules/minimap/options.lua
+++ b/ElvUI_SLE/modules/minimap/options.lua
@@ -5,7 +5,6 @@ local function configTable()
 		type = "group",
 		name = L["Minimap"],
 		order = 2,
-		disabled = function() return not E.private.general.minimap.enable end,
 		args = {
 			header = {
 				order = 1,
@@ -17,23 +16,23 @@ local function configTable()
 				type = 'description',
 				name = L['MINIMAP_DESC'],
 			},
-			enable = {
-				order = 3,
-				type = "toggle",
-				name = L["Enable"],
-				desc = L["Enable/Disable Minimap Options"],
-				get = function(info) return E.db.sle.minimap.enable end,
-				set = function(info, value) E.db.sle.minimap.enable = value; E:GetModule('Minimap'):UpdateSettings() end
-			},
 			coords = {
 				type = "group",
 				name = L["Minimap Coordinates"],
 				order = 4,
 				guiInline = true,
-				disabled = function() return not E.db.sle.minimap.enable end,
+				disabled = function() return not E.private.general.minimap.enable end,
 				args = {
+					enable = {
+						order = 1,
+						type = "toggle",
+						name = L["Enable"],
+						desc = L["Enable/Disable Minimap Coords"],
+						get = function(info) return E.db.sle.minimap.enable end,
+						set = function(info, value) E.db.sle.minimap.enable = value; E:GetModule('Minimap'):UpdateSettings() end,
+					},
 					display = {
-						order = 3,
+						order = 2,
 						type = 'select',
 						name = L['Coords Display'],
 						desc = L['Change settings for the display of the coordinates that are on the minimap.'],
@@ -42,9 +41,57 @@ local function configTable()
 						values = {
 							['MOUSEOVER'] = L['Minimap Mouseover'],
 							['SHOW'] = L['Always Display'],
-							['HIDE'] = L['Hide'],
 						},
-						--disabled = function() return not E.private.general.minimap.enable end,
+						disabled = function() return not E.db.sle.minimap.enable end,
+					},
+				},
+			},
+			buttons = {
+				type = "group",
+				name = L["Minimap Buttons"],
+				order = 5,
+				guiInline = true,
+				args = {
+					enable = {
+						order = 1,
+						type = 'toggle',
+						name = L['Enable'],
+						desc = L['Enable/Disable minimap button skinning.'],
+						get = function(info) return E.private.sle.minimap.buttons.enable end,
+						set = function(info, value) E.private.sle.minimap.buttons.enable = value; E:StaticPopup_Show("PRIVATE_RL") end,
+					},
+					anchor = {
+						order = 2,
+						type = 'select',
+						name = L['Anchor Setting'],
+						desc = L['Anchor mode for displaying the minimap buttons are skinned.'],
+						get = function(info) return E.db.sle.minimap.buttons.anchor end,
+						set = function(info, value) E.db.sle.minimap.buttons.anchor = value; E:GetModule('SquareMinimapButtons'):UpdateLayout() end,
+						values = {
+							['NOANCHOR'] = L['Minimap'],
+							['HORIZONTAL'] = L['Horizontal Bar'],
+							['VERTICAL'] = L['Vertical Bar'],
+						},
+						disabled = function() return not E.private.sle.minimap.buttons.enable end,
+					},
+					size = {
+						order = 3,
+						type = 'range',
+						name = L['Button Size'],
+						desc = L['The size of the minimap buttons when not anchored to the minimap.'],
+						min = 16, max = 40, step = 1,
+						get = function(info) return E.db.sle.minimap.buttons.size end,
+						set = function(info, value) E.db.sle.minimap.buttons.size = value; E:GetModule('SquareMinimapButtons'):UpdateLayout() end,
+						disabled = function() return not E.private.sle.minimap.buttons.enable or E.db.sle.minimap.buttons.anchor == 'NOANCHOR' end,
+					},
+					mouseover = {
+						order = 4,
+						name = L['Mouse Over'],
+						desc = L['Show minimap buttons on mouseover.'],
+						type = "toggle",
+						get = function(info) return E.db.sle.minimap.buttons.mouseover end,
+						set = function(info, value) E.db.sle.minimap.buttons.mouseover = value; E:GetModule('SquareMinimapButtons'):ChangeMouseOverSetting() end,
+						disabled = function() return not E.private.sle.minimap.buttons.enable or E.db.sle.minimap.buttons.anchor == 'NOANCHOR' end,
 					},
 				},
 			},