PageRenderTime 202ms CodeModel.GetById 80ms app.highlight 15ms RepoModel.GetById 61ms app.codeStats 0ms

/Tukui/modules/maps/zonemap.lua

http://github.com/Asphyxia/Tukui
Lua | 68 lines | 58 code | 8 blank | 2 comment | 9 complexity | 5b6d2d10380e9dde951d0c19210b20d3 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2
 3-- BG TINY MAP (BG, mining, etc)
 4local tinymap = CreateFrame("Frame", "TukuiZoneMap", UIParent)
 5tinymap:SetPoint("CENTER")
 6tinymap:SetSize(223, 150)
 7tinymap:EnableMouse(true)
 8tinymap:SetMovable(true)
 9tinymap:RegisterEvent("ADDON_LOADED")
10tinymap:SetPoint("CENTER", UIParent, 0, 0)
11tinymap:SetFrameLevel(7)
12tinymap:Hide()
13
14-- create minimap background
15local tinymapbg = CreateFrame("Frame", nil, tinymap)
16tinymapbg:SetAllPoints()
17tinymapbg:SetFrameLevel(0)
18tinymapbg:SetTemplate("Transparent")
19
20tinymap:SetScript("OnEvent", function(self, event, addon)
21	if addon ~= "Blizzard_BattlefieldMinimap" then return end
22
23	BattlefieldMinimap:SetScript("OnShow", function(self)
24		tinymap:Show()		
25		BattlefieldMinimapCorner:Kill()
26		BattlefieldMinimapBackground:Kill()
27		BattlefieldMinimapTab:Kill()
28		BattlefieldMinimapTabLeft:Kill()
29		BattlefieldMinimapTabMiddle:Kill()
30		BattlefieldMinimapTabRight:Kill()
31		self:SetParent(tinymap)
32		self:SetPoint("TOPLEFT", tinymap, "TOPLEFT", 2, -2)
33		self:SetFrameStrata(tinymap:GetFrameStrata())
34		BattlefieldMinimapCloseButton:ClearAllPoints()
35		BattlefieldMinimapCloseButton:SetPoint("TOPRIGHT", -4, 0)
36		BattlefieldMinimap:SetFrameLevel(6)
37		BattlefieldMinimapCloseButton:SetFrameLevel(8)
38		tinymap:SetScale(1)
39		tinymap:SetAlpha(1)
40		
41		BattlefieldMinimap_Update() --BugFix map not update on initial show
42	end)
43
44	BattlefieldMinimap:SetScript("OnHide", function(self)
45		tinymap:SetScale(0.00001)
46		tinymap:SetAlpha(0)
47	end)
48
49	tinymap:SetScript("OnMouseUp", function(self, btn)
50		if btn == "LeftButton" then
51			self:StopMovingOrSizing()
52			if OpacityFrame:IsShown() then OpacityFrame:Hide() end -- seem to be a bug with default ui in 4.0, we hide it on next click
53		elseif btn == "RightButton" then
54			ToggleDropDownMenu(1, nil, BattlefieldMinimapTabDropDown, self:GetName(), 0, -4)
55			if OpacityFrame:IsShown() then OpacityFrame:Hide() end -- seem to be a bug with default ui in 4.0, we hide it on next click
56		end
57	end)
58
59	tinymap:SetScript("OnMouseDown", function(self, btn)
60		if btn == "LeftButton" then
61			if BattlefieldMinimapOptions and BattlefieldMinimapOptions.locked then
62				return
63			else
64				self:StartMoving()
65			end
66		end
67	end)
68end)