PageRenderTime 255ms CodeModel.GetById 111ms app.highlight 12ms RepoModel.GetById 129ms app.codeStats 0ms

/Tukui/modules/skins/worldmap.lua

http://github.com/Asphyxia/Tukui
Lua | 262 lines | 215 code | 44 blank | 3 comment | 33 complexity | 788242a3fd7f092e8a3a4e13fd6b2b64 MD5 | raw file
  1local T, C, L = unpack(select(2, ...))
  2
  3local Taint = T.FullMapQuestTaintFix
  4
  5local function LoadSkin()
  6	WorldMapFrame:CreateBackdrop("Transparent")
  7	WorldMapDetailFrame.backdrop = CreateFrame("Frame", nil, WorldMapFrame)
  8	WorldMapDetailFrame.backdrop:SetTemplate("Transparent")
  9	WorldMapDetailFrame.backdrop:Point("TOPLEFT", WorldMapDetailFrame, "TOPLEFT", -2, 2)
 10	WorldMapDetailFrame.backdrop:Point("BOTTOMRIGHT", WorldMapDetailFrame, "BOTTOMRIGHT", 2, -2)
 11	WorldMapDetailFrame.backdrop:SetFrameLevel(WorldMapDetailFrame:GetFrameLevel() - 2)
 12
 13	T.SkinCloseButton(WorldMapFrameCloseButton)
 14	T.SkinCloseButton(WorldMapFrameSizeDownButton)
 15	T.SkinCloseButton(WorldMapFrameSizeUpButton)
 16							
 17	T.SkinDropDownBox(WorldMapLevelDropDown)
 18	T.SkinDropDownBox(WorldMapZoneMinimapDropDown)
 19	T.SkinDropDownBox(WorldMapContinentDropDown)
 20	T.SkinDropDownBox(WorldMapZoneDropDown)
 21	T.SkinButton(WorldMapZoomOutButton)
 22	WorldMapZoomOutButton:Point("LEFT", WorldMapZoneDropDown, "RIGHT", 0, 4)
 23	WorldMapLevelUpButton:Point("TOPLEFT", WorldMapLevelDropDown, "TOPRIGHT", -2, 8)
 24	WorldMapLevelDownButton:Point("BOTTOMLEFT", WorldMapLevelDropDown, "BOTTOMRIGHT", -2, 2)
 25
 26	T.SkinCheckBox(WorldMapTrackQuest)
 27	T.SkinCheckBox(WorldMapQuestShowObjectives)
 28	T.SkinCheckBox(WorldMapShowDigSites)
 29
 30	--Mini
 31	local function SmallSkin()
 32		WorldMapLevelDropDown:ClearAllPoints()
 33		WorldMapLevelDropDown:Point("TOPLEFT", WorldMapDetailFrame, "TOPLEFT", -10, -4)
 34
 35		WorldMapFrame.backdrop:ClearAllPoints()
 36		WorldMapFrame.backdrop:Point("TOPLEFT", 2, 2)
 37		WorldMapFrame.backdrop:Point("BOTTOMRIGHT", 2, -2)
 38	end
 39
 40	--Large
 41	local function LargeSkin()
 42		if not InCombatLockdown() then
 43			WorldMapFrame:SetParent(UIParent)
 44			WorldMapFrame:EnableMouse(false)
 45			WorldMapFrame:EnableKeyboard(false)
 46			SetUIPanelAttribute(WorldMapFrame, "area", "center");
 47			SetUIPanelAttribute(WorldMapFrame, "allowOtherPanels", true)
 48		end
 49		
 50		WorldMapFrame.backdrop:ClearAllPoints()
 51		WorldMapFrame.backdrop:Point("TOPLEFT", WorldMapDetailFrame, "TOPLEFT", -25, 70)
 52		WorldMapFrame.backdrop:Point("BOTTOMRIGHT", WorldMapDetailFrame, "BOTTOMRIGHT", 25, -30)    
 53	end
 54
 55	local function QuestSkin()
 56		if not InCombatLockdown() then
 57			WorldMapFrame:SetParent(UIParent)
 58			WorldMapFrame:EnableMouse(false)
 59			WorldMapFrame:EnableKeyboard(false)
 60			SetUIPanelAttribute(WorldMapFrame, "area", "center");
 61			SetUIPanelAttribute(WorldMapFrame, "allowOtherPanels", true)
 62		end
 63		
 64		WorldMapFrame.backdrop:ClearAllPoints()
 65		WorldMapFrame.backdrop:Point("TOPLEFT", WorldMapDetailFrame, "TOPLEFT", -25, 70)
 66		WorldMapFrame.backdrop:Point("BOTTOMRIGHT", WorldMapDetailFrame, "BOTTOMRIGHT", 325, -235)  
 67		
 68		if not WorldMapQuestDetailScrollFrame.backdrop then
 69			WorldMapQuestDetailScrollFrame:CreateBackdrop("Transparent")
 70			WorldMapQuestDetailScrollFrame.backdrop:Point("TOPLEFT", -22, 2)
 71			WorldMapQuestDetailScrollFrame.backdrop:Point("BOTTOMRIGHT", 23, -4)
 72		end
 73		
 74		if not WorldMapQuestRewardScrollFrame.backdrop then
 75			WorldMapQuestRewardScrollFrame:CreateBackdrop("Transparent")
 76			WorldMapQuestRewardScrollFrame.backdrop:Point("BOTTOMRIGHT", 22, -4)				
 77		end
 78		
 79		if not WorldMapQuestScrollFrame.backdrop then
 80			WorldMapQuestScrollFrame:CreateBackdrop("Transparent")
 81			WorldMapQuestScrollFrame.backdrop:Point("TOPLEFT", 0, 2)
 82			WorldMapQuestScrollFrame.backdrop:Point("BOTTOMRIGHT", 24, -3)				
 83		end
 84	end			
 85
 86	local function FixSkin()
 87		WorldMapFrame:StripTextures()
 88		if WORLDMAP_SETTINGS.size == WORLDMAP_FULLMAP_SIZE then
 89			LargeSkin()
 90		elseif WORLDMAP_SETTINGS.size == WORLDMAP_WINDOWED_SIZE then
 91			SmallSkin()
 92		elseif WORLDMAP_SETTINGS.size == WORLDMAP_QUESTLIST_SIZE then
 93			QuestSkin()
 94		end
 95
 96		if not InCombatLockdown() then
 97			WorldMapFrame:SetScale(1)
 98			WorldMapFrameSizeDownButton:Show()
 99			WorldMapFrame:SetFrameLevel(40)
100			WorldMapFrame:SetFrameStrata("HIGH")
101		end
102		
103		WorldMapFrameAreaLabel:SetFont(C["media"].font, 50, "OUTLINE")
104		WorldMapFrameAreaLabel:SetShadowOffset(2, -2)
105		WorldMapFrameAreaLabel:SetTextColor(0.90, 0.8294, 0.6407)	
106		
107		WorldMapFrameAreaDescription:SetFont(C["media"].font, 40, "OUTLINE")
108		WorldMapFrameAreaDescription:SetShadowOffset(2, -2)	
109		
110		WorldMapZoneInfo:SetFont(C["media"].font, 27, "OUTLINE")
111		WorldMapZoneInfo:SetShadowOffset(2, -2)		
112	end
113
114	WorldMapFrame:HookScript("OnShow", FixSkin)
115	hooksecurefunc("WorldMapFrame_SetFullMapView", LargeSkin)
116	hooksecurefunc("WorldMapFrame_SetQuestMapView", QuestSkin)
117	hooksecurefunc("WorldMap_ToggleSizeUp", function() 
118		if WORLDMAP_SETTINGS.size == WORLDMAP_QUESTLIST_SIZE then
119			Taint = true
120		end
121		FixSkin() 
122	end)
123
124	WorldMapFrame:RegisterEvent("PLAYER_LOGIN")
125	WorldMapFrame:RegisterEvent("PLAYER_REGEN_ENABLED") -- fix taint with small map & big map
126	WorldMapFrame:RegisterEvent("PLAYER_REGEN_DISABLED") -- fix taint with small map & big map
127	WorldMapFrame:HookScript("OnEvent", function(self, event)
128		local miniWorldMap = GetCVarBool("miniWorldMap")
129		local quest = WorldMapQuestShowObjectives:GetChecked()
130
131		if event == "PLAYER_LOGIN" then
132			if not miniWorldMap then
133				ToggleFrame(WorldMapFrame)
134				ToggleFrame(WorldMapFrame)
135			end
136		elseif event == "PLAYER_REGEN_DISABLED" then
137			WorldMapFrameSizeDownButton:Disable()
138			WorldMapFrameSizeUpButton:Disable()
139			
140			if (quest) and (miniWorldMap or Taint) then
141				if WorldMapFrame:IsShown() then
142					HideUIPanel(WorldMapFrame)
143				end
144
145				if not miniWorldMap and Taint and WORLDMAP_SETTINGS.size == WORLDMAP_QUESTLIST_SIZE then
146					WorldMapFrame_SetFullMapView()
147				end
148
149				WatchFrame.showObjectives = nil
150				WorldMapTitleButton:Hide()
151				WorldMapBlobFrame:Hide()
152				WorldMapPOIFrame:Hide()
153
154				WorldMapQuestShowObjectives.Show = T.dummy
155				WorldMapTitleButton.Show = T.dummy
156				WorldMapBlobFrame.Show = T.dummy
157				WorldMapPOIFrame.Show = T.dummy
158
159				WatchFrame_Update()
160			end
161			WorldMapQuestShowObjectives:Hide()
162		elseif event == "PLAYER_REGEN_ENABLED" then
163			WorldMapFrameSizeDownButton:Enable()
164			WorldMapFrameSizeUpButton:Enable()
165			
166			if (quest) and (miniWorldMap or Taint) then
167				WorldMapQuestShowObjectives.Show = WorldMapQuestShowObjectives:Show()
168				WorldMapTitleButton.Show = WorldMapTitleButton:Show()
169				WorldMapBlobFrame.Show = WorldMapBlobFrame:Show()
170				WorldMapPOIFrame.Show = WorldMapPOIFrame:Show()
171
172				WorldMapTitleButton:Show()
173
174				WatchFrame.showObjectives = true
175
176				if not miniWorldMap and Taint and WORLDMAP_SETTINGS.size == WORLDMAP_FULLMAP_SIZE then
177					WorldMapFrame_SetFullMapView()
178				end
179
180				WorldMapBlobFrame:Show()
181				WorldMapPOIFrame:Show()
182
183				WatchFrame_Update()
184				
185				if Taint and not miniWorldMap and WorldMapFrame:IsShown() and WORLDMAP_SETTINGS.size == WORLDMAP_FULLMAP_SIZE then
186					HideUIPanel(WorldMapFrame)
187					ShowUIPanel(WorldMapFrame)
188				end
189			end
190			WorldMapQuestShowObjectives:Show()
191		end
192	end)
193
194	local coords = CreateFrame("Frame", "CoordsFrame", WorldMapFrame)
195	local fontheight = select(2, WorldMapQuestShowObjectivesText:GetFont())*1.1
196	coords:SetFrameLevel(90)
197	coords:FontString("PlayerText", C["media"].font, fontheight, "THINOUTLINE")
198	coords:FontString("MouseText", C["media"].font, fontheight, "THINOUTLINE")
199	coords.PlayerText:SetTextColor(WorldMapQuestShowObjectivesText:GetTextColor())
200	coords.MouseText:SetTextColor(WorldMapQuestShowObjectivesText:GetTextColor())
201	coords.PlayerText:SetPoint("BOTTOMLEFT", WorldMapDetailFrame, "BOTTOMLEFT", 5, 5)
202	coords.PlayerText:SetText("Player:   0, 0")
203	coords.MouseText:SetPoint("BOTTOMLEFT", coords.PlayerText, "TOPLEFT", 0, 5)
204	coords.MouseText:SetText("Mouse:   0, 0")
205	local int = 0
206
207	WorldMapFrame:HookScript("OnUpdate", function(self, elapsed)
208		if WORLDMAP_SETTINGS.size == WORLDMAP_FULLMAP_SIZE then
209			WorldMapFrameSizeUpButton:Hide()
210			WorldMapFrameSizeDownButton:Show()
211		elseif WORLDMAP_SETTINGS.size == WORLDMAP_WINDOWED_SIZE then
212			WorldMapFrameSizeUpButton:Show()
213			WorldMapFrameSizeDownButton:Hide()
214		elseif WORLDMAP_SETTINGS.size == WORLDMAP_QUESTLIST_SIZE then
215			WorldMapFrameSizeUpButton:Hide()
216			WorldMapFrameSizeDownButton:Show()
217		end		
218
219		int = int + 1
220		
221		if int >= 3 then
222			local inInstance, _ = IsInInstance()
223			local x,y = GetPlayerMapPosition("player")
224			x = math.floor(100 * x)
225			y = math.floor(100 * y)
226			if x ~= 0 and y ~= 0 then
227				coords.PlayerText:SetText(PLAYER..":   "..x..", "..y)
228			else
229				coords.PlayerText:SetText(" ")
230			end
231			
232
233			local scale = WorldMapDetailFrame:GetEffectiveScale()
234			local width = WorldMapDetailFrame:GetWidth()
235			local height = WorldMapDetailFrame:GetHeight()
236			local centerX, centerY = WorldMapDetailFrame:GetCenter()
237			local x, y = GetCursorPosition()
238			local adjustedX = (x / scale - (centerX - (width/2))) / width
239			local adjustedY = (centerY + (height/2) - y / scale) / height	
240
241			if (adjustedX >= 0  and adjustedY >= 0 and adjustedX <= 1 and adjustedY <= 1) then
242				adjustedX = math.floor(100 * adjustedX)
243				adjustedY = math.floor(100 * adjustedY)
244				coords.MouseText:SetText(MOUSE_LABEL..":   "..adjustedX..", "..adjustedY)
245			else
246				coords.MouseText:SetText(" ")
247			end
248			
249			int = 0
250		end				
251	end)
252
253	-- dropdown on full map is scaled incorrectly
254	WorldMapContinentDropDownButton:HookScript("OnClick", function() DropDownList1:SetScale(C.general.uiscale) end)
255	WorldMapZoneDropDownButton:HookScript("OnClick", function(self) 
256		DropDownList1:SetScale(C.general.uiscale)
257		DropDownList1:ClearAllPoints()
258		DropDownList1:Point("TOPRIGHT", self, "BOTTOMRIGHT", 2, -4)
259	end)
260end
261
262tinsert(T.SkinFuncs["Tukui"], LoadSkin)