PageRenderTime 146ms CodeModel.GetById 61ms app.highlight 41ms RepoModel.GetById 39ms app.codeStats 0ms

/Tukui_Raid_Healing/oUF_hTukz_Raid16_40.lua

http://github.com/Asphyxia/Tukui
Lua | 349 lines | 278 code | 50 blank | 21 comment | 31 complexity | 0ace005386eab09cc388f7a5b71f8d4d MD5 | raw file
  1local ADDON_NAME, ns = ...
  2local oUF = oUFTukui or oUF
  3assert(oUF, "Tukui was unable to locate oUF install.")
  4
  5ns._Objects = {}
  6ns._Headers = {}
  7
  8local T, C, L = unpack(Tukui) -- Import: T - functions, constants, variables; C - config; L - locales
  9if not C["unitframes"].enable == true then return end
 10
 11local font2 = C["media"].uffont
 12local font1 = C["media"].font
 13local normTex = C["media"].normTex
 14local font = C["media"].pixelfont
 15
 16local function Shared(self, unit)
 17	self.colors = T.oUF_colors
 18	self:RegisterForClicks("AnyUp")
 19	self:SetScript('OnEnter', UnitFrame_OnEnter)
 20	self:SetScript('OnLeave', UnitFrame_OnLeave)
 21	
 22	self.menu = T.SpawnMenu
 23	
 24	local health = CreateFrame('StatusBar', nil, self)
 25	health:SetPoint("TOPLEFT")
 26	health:SetPoint("TOPRIGHT")
 27	health:Height(28*C["unitframes"].gridscale*T.raidscale)
 28	health:SetStatusBarTexture(C["media"].normTex)
 29	self.Health = health
 30	
 31	if C["unitframes"].gridhealthvertical == true then
 32		health:SetOrientation('VERTICAL')
 33	end
 34	
 35	health.bg = health:CreateTexture(nil, 'BORDER')
 36	health.bg:SetAllPoints(health)
 37	health.bg:SetTexture(C["media"].normTex)
 38	health.bg:SetTexture(1, 1, 1)
 39	health.bg.multiplier = (0.3)
 40	self.Health.bg = health.bg
 41	
 42	local HealthBorder = CreateFrame("Frame", nil, health)
 43	HealthBorder:SetPoint("TOPLEFT", health, "TOPLEFT", T.Scale(-2), T.Scale(2))
 44	HealthBorder:SetPoint("BOTTOMRIGHT", health, "BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
 45	HealthBorder:SetTemplate("Default")
 46	HealthBorder:CreateShadow("Default")
 47	HealthBorder:SetFrameLevel(2)
 48	self.HealthBorder = HealthBorder
 49		
 50	health.value = health:CreateFontString(nil, "OVERLAY")
 51	health.value:Point("CENTER", health, 1, -1)
 52	health.value:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
 53	health.value:SetTextColor(1,1,1)
 54	health.value:SetShadowOffset(1, -1)
 55	self.Health.value = health.value
 56	
 57	health.PostUpdate = T.PostUpdateHealthRaid
 58	
 59	health.frequentUpdates = true
 60	
 61	if C.unitframes.unicolor == true then
 62		health.colorDisconnected = false
 63		health.colorClass = false
 64		health:SetStatusBarColor(.150, .150, .150, 1)
 65		health.bg:SetVertexColor(0, 0, 0, 1)		
 66	else
 67		health.colorDisconnected = true
 68		health.colorClass = true
 69		health.colorReaction = true			
 70	end
 71	
 72	if C.unitframes.gradienthealth and C.unitframes.unicolor then
 73		self:HookScript("OnEnter", function(self)
 74			if not UnitIsConnected(self.unit) or UnitIsDead(self.unit) or UnitIsGhost(self.unit) or (not UnitInRange(self.unit) and not UnitIsPlayer(self.unit)) then return end
 75			local hover = RAID_CLASS_COLORS[select(2, UnitClass(self.unit))]
 76			health:SetStatusBarColor(hover.r, hover.g, hover.b)
 77			health.classcolored = true
 78		end)
 79
 80		self:HookScript("OnLeave", function(self)
 81			if not UnitIsConnected(self.unit) or UnitIsDead(self.unit) or UnitIsGhost(self.unit) then return end
 82			local r, g, b = oUF.ColorGradient(UnitHealth(self.unit)/UnitHealthMax(self.unit), unpack(C["unitframes"].gradient))
 83			health:SetStatusBarColor(r, g, b)
 84			health.classcolored = false
 85		end)
 86	end
 87		
 88	local power = CreateFrame("StatusBar", nil, self)
 89	power:SetHeight(1.5*C["unitframes"].gridscale*T.raidscale)
 90	power:SetWidth(54)
 91	power:Point("CENTER", self.Health, "CENTER", 0, -10)
 92	power:SetStatusBarTexture(C["media"].normTex)
 93	power:SetFrameLevel(self.Health:GetFrameLevel() + 2)
 94	self.Power = power
 95
 96	power.frequentUpdates = true
 97	power.colorDisconnected = true
 98
 99	power.bg = power:CreateTexture(nil, "BORDER")
100	power.bg:SetAllPoints(power)
101	power.bg:SetTexture(C["media"].normTex)
102	power.bg:SetAlpha(1)
103	power.bg.multiplier = .4
104	
105	local PowerBorder = CreateFrame("Frame", nil, power)
106	PowerBorder:SetPoint("TOPLEFT", power, "TOPLEFT", T.Scale(-2), T.Scale(2))
107	PowerBorder:SetPoint("BOTTOMRIGHT", power, "BOTTOMRIGHT", T.Scale(2), T.Scale(-2))
108	PowerBorder:SetTemplate("Thin")
109	PowerBorder:SetFrameLevel(power:GetFrameLevel() - 1)
110	self.PowerBorder = PowerBorder
111	
112	if C.unitframes.unicolor == true then
113		power.colorClass = true
114		power.bg.multiplier = 0.1				
115	else
116		power.colorPower = true
117	end
118	
119	local name = self.Health:CreateFontString(nil, "OVERLAY")
120    name:SetPoint("TOP", 0, 18) 
121	name:SetPoint("BOTTOM") 
122	name:SetPoint("LEFT", 4, 0) 
123	name:SetPoint("RIGHT")
124	name:SetFont(font, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
125	name:SetShadowOffset(1.25, -1.25)
126	self:Tag(name, "[Tukui:getnamecolor][Tukui:nameshort]")
127	self.Name = name
128	
129	local leader = health:CreateTexture(nil, "OVERLAY")
130    leader:Height(12*T.raidscale)
131    leader:Width(12*T.raidscale)
132    leader:SetPoint("TOPLEFT", 0, 10)
133	self.Leader = leader
134	
135    local MasterLooter = health:CreateTexture(nil, "OVERLAY")
136    MasterLooter:Height(12*T.raidscale)
137    MasterLooter:Width(12*T.raidscale)
138	self.MasterLooter = MasterLooter
139    self:RegisterEvent("PARTY_LEADER_CHANGED", T.MLAnchorUpdate)
140    self:RegisterEvent("PARTY_MEMBERS_CHANGED", T.MLAnchorUpdate)
141	
142	local LFDRole = health:CreateTexture(nil, "OVERLAY")
143    LFDRole:Height(14*T.raidscale)
144    LFDRole:Width(14*T.raidscale)
145	LFDRole:Point("TOP", 0, 10)
146	LFDRole:SetTexture("Interface\\AddOns\\Tukui\\medias\\textures\\lfdicons.blp")
147	self.LFDRole = LFDRole
148	
149	
150    if C["unitframes"].aggro == true then
151		table.insert(self.__elements, T.UpdateThreat)
152		self:RegisterEvent('PLAYER_TARGET_CHANGED', T.UpdateThreat)
153		self:RegisterEvent('UNIT_THREAT_LIST_UPDATE', T.UpdateThreat)
154		self:RegisterEvent('UNIT_THREAT_SITUATION_UPDATE', T.UpdateThreat)
155	end
156	
157	if C["unitframes"].showsymbols == true then
158		local RaidIcon = power:CreateTexture(nil, 'OVERLAY')
159		RaidIcon:Height(18*T.raidscale)
160		RaidIcon:Width(18*T.raidscale)
161		RaidIcon:SetPoint('CENTER', self, 'TOP')
162		RaidIcon:SetTexture("Interface\\AddOns\\Tukui\\medias\\textures\\raidicons.blp") -- thx hankthetank for texture
163		self.RaidIcon = RaidIcon
164	end
165	
166	local ReadyCheck = health:CreateTexture(nil, "OVERLAY")
167	ReadyCheck:Height(12*C["unitframes"].gridscale*T.raidscale)
168	ReadyCheck:Width(12*C["unitframes"].gridscale*T.raidscale)
169	ReadyCheck:Point("TOP", 0, 6) 	
170	self.ReadyCheck = ReadyCheck
171	
172	--local picon = self.Health:CreateTexture(nil, 'OVERLAY')
173	--picon:SetPoint('CENTER', self.Health)
174	--picon:SetSize(16, 16)
175	--picon:SetTexture[[Interface\AddOns\Tukui\medias\textures\picon]]
176	--picon.Override = T.Phasing
177	--self.PhaseIcon = picon
178	
179	if not C["unitframes"].raidunitdebuffwatch == true then
180		self.DebuffHighlightAlpha = 1
181		self.DebuffHighlightBackdrop = true
182		self.DebuffHighlightFilter = true
183	end
184	
185	if C["unitframes"].showrange == true then
186		local range = {insideAlpha = 1, outsideAlpha = C["unitframes"].raidalphaoor}
187		self.Range = range
188	end
189	
190	if C["unitframes"].showsmooth == true then
191		health.Smooth = true
192		power.Smooth = true
193	end
194	
195	if C["unitframes"].healcomm then
196		local mhpb = CreateFrame('StatusBar', nil, self.Health)
197		if C["unitframes"].gridhealthvertical then
198			mhpb:SetOrientation("VERTICAL")
199			mhpb:SetPoint('BOTTOM', self.Health:GetStatusBarTexture(), 'TOP', 0, 0)
200			mhpb:Width(66*C["unitframes"].gridscale*T.raidscale)
201			mhpb:Height(50*C["unitframes"].gridscale*T.raidscale)		
202		else
203			mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
204			mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
205			mhpb:Width(66*C["unitframes"].gridscale*T.raidscale)
206		end				
207		mhpb:SetStatusBarTexture(C["media"].normTex)
208		mhpb:SetStatusBarColor(0, 1, 0.5, 0.25)
209
210		local ohpb = CreateFrame('StatusBar', nil, self.Health)
211		if C["unitframes"].gridhealthvertical then
212			ohpb:SetOrientation("VERTICAL")
213			ohpb:SetPoint('BOTTOM', mhpb:GetStatusBarTexture(), 'TOP', 0, 0)
214			ohpb:Width(66*C["unitframes"].gridscale*T.raidscale)
215			ohpb:Height(50*C["unitframes"].gridscale*T.raidscale)
216		else
217			ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0)
218			ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0)
219			ohpb:Width(6*C["unitframes"].gridscale*T.raidscale)
220		end
221		ohpb:SetStatusBarTexture(C["media"].normTex)
222		ohpb:SetStatusBarColor(0, 1, 0, 0.25)
223
224		self.HealPrediction = {
225			myBar = mhpb,
226			otherBar = ohpb,
227			maxOverflow = 1,
228		}
229	end
230	
231	--Resurrect Indicator
232	local Resurrect = CreateFrame('Frame', nil, self)
233	Resurrect:SetFrameLevel(20)
234
235	local ResurrectIcon = Resurrect:CreateTexture(nil, "OVERLAY")
236	ResurrectIcon:Point(health.value:GetPoint())
237	ResurrectIcon:Size(30, 25)
238	ResurrectIcon:SetDrawLayer('OVERLAY', 7)
239
240	self.ResurrectIcon = ResurrectIcon
241	
242	if C["unitframes"].raidunitdebuffwatch == true then
243		T.createAuraWatch(self,unit)
244		
245		-- Raid Debuffs (big middle icon)
246		local RaidDebuffs = CreateFrame('Frame', nil, self)
247		RaidDebuffs:Height(21*C["unitframes"].gridscale)
248		RaidDebuffs:Width(21*C["unitframes"].gridscale)
249		RaidDebuffs:Point('CENTER', health, 1,1)
250		RaidDebuffs:SetFrameStrata(power:GetFrameStrata())
251		RaidDebuffs:SetFrameLevel(power:GetFrameLevel() + 2)
252		
253		RaidDebuffs:SetTemplate("Default")
254		
255		RaidDebuffs.icon = RaidDebuffs:CreateTexture(nil, 'OVERLAY')
256		RaidDebuffs.icon:SetTexCoord(.1,.9,.1,.9)
257		RaidDebuffs.icon:Point("TOPLEFT", 2, -2)
258		RaidDebuffs.icon:Point("BOTTOMRIGHT", -2, 2)
259		
260		-- just in case someone want to add this feature, uncomment to enable it
261		if C["unitframes"].auratimer then
262			RaidDebuffs.cd = CreateFrame('Cooldown', nil, RaidDebuffs)
263			RaidDebuffs.cd:SetPoint("TOPLEFT", T.Scale(2), T.Scale(-2))
264			RaidDebuffs.cd:SetPoint("BOTTOMRIGHT", T.Scale(-2), T.Scale(2))
265			RaidDebuffs.cd.noOCC = true -- remove this line if you want cooldown number on it
266		end
267		
268		RaidDebuffs.count = RaidDebuffs:CreateFontString(nil, 'OVERLAY')
269		RaidDebuffs.count:SetFont(C["media"].pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
270		RaidDebuffs.count:SetPoint('BOTTOMRIGHT', RaidDebuffs, 'BOTTOMRIGHT', 0, 2)
271		RaidDebuffs.count:SetTextColor(1, .9, 0)
272		
273		RaidDebuffs:FontString('time', C["media"].pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
274		RaidDebuffs.time:SetPoint('CENTER')
275		RaidDebuffs.time:SetTextColor(1, .9, 0)
276		
277		self.RaidDebuffs = RaidDebuffs
278    end
279
280	return self
281end
282
283 --[[ -- switch layout
284	local swlicon = CreateFrame("Frame", "TukuiSwitchLayoutIcon", UIParent)
285	swlicon:CreatePanel("Default", 20, 20, "LEFT", TukuiInfoLeft, "RIGHT", 8, 0)
286	swlicon:SetFrameStrata("BACKGROUND")
287	swlicon:SetFrameLevel(2)
288	swlicon:CreateShadow("Hydra")
289
290	local tex = swlicon:CreateTexture(nil, "OVERLAY")
291	tex:SetTexture(C.media.switchlayoutheal)
292	tex:SetPoint("TOPLEFT", swlicon, "TOPLEFT", 2, -2)
293	tex:SetPoint("BOTTOMRIGHT", swlicon, "BOTTOMRIGHT", -2, 2)--]]
294
295oUF:RegisterStyle('TukuiHealR25R40', Shared)
296oUF:Factory(function(self)
297	oUF:SetActiveStyle("TukuiHealR25R40")
298	if C["unitframes"].gridonly then
299		local raid = self:SpawnHeader("TukuiGrid", nil, "raid,party",
300			'oUF-initialConfigFunction', [[
301				local header = self:GetParent()
302				self:SetWidth(header:GetAttribute('initial-width'))
303				self:SetHeight(header:GetAttribute('initial-height'))
304			]],
305			'initial-width', 68,
306			'initial-height', 32,
307			"showParty", true,
308			"showPlayer", C["unitframes"].showplayerinparty,
309			"showRaid", true,
310			"xoffset", 4,
311			"yOffset", -1,
312			"point", "LEFT",
313			"groupFilter", "1,2,3,4,5,6,7,8",
314			"groupingOrder", "1,2,3,4,5,6,7,8",
315			"groupBy", "GROUP",
316			"maxColumns", 8,
317			"unitsPerColumn", 5,
318			"columnSpacing", 1,
319			"columnAnchorPoint", "TOP"
320		)
321		local RaidMove = CreateFrame("Frame")
322		RaidMove:RegisterEvent("PLAYER_LOGIN")
323		RaidMove:RegisterEvent("RAID_ROSTER_UPDATE")
324		RaidMove:RegisterEvent("PARTY_LEADER_CHANGED")
325		RaidMove:RegisterEvent("PARTY_MEMBERS_CHANGED")
326		RaidMove:SetScript("OnEvent", function(self)
327			local numraid = GetNumRaidMembers()
328			if numraid > 25 then
329				raid:Point("TOP", UIParent, "BOTTOM", 0, 415)
330			else
331				raid:Point("TOP", UIParent, "BOTTOM", 0 , 350)
332			end
333		end)
334	end
335end)
336
337-- only show 5 groups in raid (25 mans raid)
338local MaxGroup = CreateFrame("Frame")
339MaxGroup:RegisterEvent("PLAYER_ENTERING_WORLD")
340MaxGroup:RegisterEvent("ZONE_CHANGED_NEW_AREA")
341MaxGroup:SetScript("OnEvent", function(self)
342	local inInstance, instanceType = IsInInstance()
343	local _, _, _, _, maxPlayers, _, _ = GetInstanceInfo()
344	if inInstance and instanceType == "raid" and maxPlayers ~= 40 then
345		TukuiGrid:SetAttribute("groupFilter", "1,2,3,4,5")
346	else
347		TukuiGrid:SetAttribute("groupFilter", "1,2,3,4,5,6,7,8")
348	end
349end)