-
-
Save anonymous/50c4497b6f3b960d63b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- table of spells | |
cfg.raidAuras = { | |
[GetSpellInfo(2584)] = true, -- waiting to ressurect | |
[GetSpellInfo(11426)] = true, -- ice barrier | |
[GetSpellInfo(159916)] = true, -- amplify magic | |
[GetSpellInfo(33076)] = true, -- prayer of mending | |
} | |
-- raidframes | |
-- obble | |
-- this code is written using ShotGlass as a base | |
-- thanks to danltiger & pinghasen | |
-- http://www.wowinterface.com/downloads/info18776-ShotGlassRaidFrames.html | |
-- extensively restyled/heavily rewritten. | |
-- ToDo: finish aura tracking | |
-- % hp display? | |
-- rewrite the way we size and scale things because jesus christ what the hell | |
-- ns | |
local _, cfg = ... | |
-- set how often the range indicator updates | |
local rangePollFrequency = .5 | |
-- function list | |
local UpdateButton, OnShowButton, OnChangeAttribute, OnEvent, SetHandlers | |
local CreateGroupHeader, CreateUnitFrameArtwork | |
local CallArtworkFunction, SecureInitFunction | |
-- role types for tooltip | |
local RoleStrings = { | |
['DAMAGER'] = DAMAGER, | |
['HEALER'] = HEALER, | |
['TANK'] = TANK, | |
} | |
-- aura colours | |
local Colors = {} | |
Colors.Grey = {r = .5, g = .5, b = .5,} | |
Colors.Red = {r = 1, g = 0, b = 0,} | |
Colors.Orange = {r = 1, g = .5, b = 0,} | |
Colors.Yellow = {r = 1, g = 1, b = 0,} | |
Colors.Green = {r = 0, g = 1, b = 0,} | |
-- !beautycase check | |
local beauty = IsAddOnLoaded('!Beautycase') | |
-- aura tracking list ------------------------------------------------------------------- | |
local TrackedAuras = {} | |
-- Clique support ----------------------------------------------------------------------- | |
ClickCastFrames = ClickCastFrames or {} | |
-- register a callback ------------------------------------------------------------------ | |
-- polls the frame until it expires | |
-- and hides the frame | |
local PollFrameUntil, DelayedStart | |
do | |
local Framelist = {} -- Key = Frame, Value = Expiration Time | |
local Watcherframe = CreateFrame('Frame') | |
local WatcherframeActive = false | |
local timeToUpdate = 0 | |
local pollInterval = 1 | |
local function CheckList(self) | |
local curTime = GetTime() | |
if curTime < timeToUpdate then return end | |
local framecount = 0 | |
timeToUpdate = curTime + pollInterval | |
-- cycle through the watchlist, hiding frames which are timed-out | |
for frame, expiration in pairs(Framelist) do | |
-- if expired... | |
if expiration < curTime then | |
Framelist[frame] = nil | |
-- if active... | |
else | |
-- update the frame | |
if frame.Poll then | |
frame:Poll(expiration) | |
end | |
framecount = framecount + 1 | |
end | |
end | |
-- if no more frames to watch, unregister the OnUpdate script | |
if framecount==0 then | |
Watcherframe:SetScript('OnUpdate', nil) | |
WatcherframeActive = false | |
end | |
end | |
function PollFrameUntil(frame, expiration) | |
if expiration==0 then | |
frame:Hide() | |
Framelist[frame] = nil | |
else | |
Framelist[frame] = expiration | |
if not WatcherframeActive then | |
Watcherframe:SetScript('OnUpdate', CheckList) | |
WatcherframeActive = true | |
end | |
end | |
end | |
end | |
-- abbreviate names --------------------------------------------------------------------- | |
-- now with utf8 support | |
local function TruncateName(text) | |
if text then | |
return text:utf8sub(1, 3) | |
end | |
end | |
-- Tooltip ------------------------------------------------------------------------------ | |
-- show out-of-InCombatLockdown() | |
local function ShowUnitTooltip(frame) | |
local unitid = frame.UnitID | |
if not InCombatLockdown() then | |
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent) | |
GameTooltip:SetUnit(unitid) | |
role = UnitGroupRolesAssigned(unitid) | |
if role and role~='NONE' then GameTooltip:AddLine(RoleStrings[role]) end | |
GameTooltip:Show() | |
end | |
end | |
-- hide | |
local function HideUnitTooltip() | |
if not InCombatLockdown() then | |
GameTooltip:FadeOut() | |
end | |
end | |
-- poll for range & ready check --------------------------------------------------------- | |
local function PollOnUpdate(self, elapsed) | |
local unitid = self.UnitID | |
if not unitid then return end | |
local now = GetTime() | |
if now > self.rangeUpdateTime then | |
self.rangeUpdateTime = now + rangePollFrequency | |
else | |
return | |
end | |
-- range check | |
local raidindex = GetRaidTargetIndex(unitid) | |
-- stop overwriting the raid icons | |
if raidindex then | |
self.Graphics.Text:SetText(ICON_LIST[raidindex]..'22|t') | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 8) | |
elseif UnitInRange(unitid) then | |
self.Graphics.Text:SetText('• '..TruncateName(UnitName(unitid))) | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
else | |
self.Graphics.Text:SetText(TruncateName(UnitName(unitid))) | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
end | |
-- ready check | |
local total = 0 | |
total = total + elapsed | |
local timeLeft = GetReadyCheckTimeLeft() | |
local rcheck = GetReadyCheckStatus(unitid) | |
if rcheck and rcheck~=nil then | |
local readyCheckStatus = GetReadyCheckStatus(unitid) | |
self.readyCheckStatus = readyCheckStatus | |
if readyCheckStatus=='ready' then | |
self.Graphics.readyCheckIcon:SetTexture(READY_CHECK_READY_TEXTURE) | |
self.Graphics.readyCheckIcon:Show() | |
elseif readyCheckStatus=='notready' then | |
self.Graphics.readyCheckIcon:SetTexture(READY_CHECK_NOT_READY_TEXTURE) | |
self.Graphics.readyCheckIcon:Show() | |
elseif readyCheckStatus=='waiting' then | |
self.Graphics.readyCheckIcon:SetTexture(READY_CHECK_WAITING_TEXTURE) | |
self.Graphics.readyCheckIcon:Show() | |
else | |
self.Graphics.readyCheckIcon:Hide() | |
end | |
elseif rcheck and rcheck==nil then | |
if timeLeft<=0 then | |
if total>=11 then | |
self.Graphics.readyCheckIcon:Hide() | |
end | |
end | |
else | |
self.Graphics.readyCheckIcon:Hide() | |
end | |
end | |
-- hides party frames ------------------------------------------------------------------- | |
--[[for i=1,4 do | |
local frame = _G['PartyMemberFrame'..i] | |
frame:UnregisterAllEvents() | |
frame.Show = function() end | |
frame:Hide() | |
end]] | |
-- event handler | |
local UnitEventHandlers = {} | |
-- AURAS | |
-- dispel table | |
local dispel_list = { | |
DRUID = {Curse = true, Poison = true}, | |
MAGE = {Curse = true}, | |
PALADIN = {Disease = true, Magic = true, Poison = true}, | |
PRIEST = {Disease = true, Magic = true}, | |
SHAMAN = {Curse = true, Disease = true, Poison = true}, | |
} | |
local dispel = dispel_list[select(2, UnitClass('player'))] | |
local function raid_Auras(self, unit) | |
for i = 1, 40 do | |
local name, _, icon, _, dtype, duration, _, _, _, _, id, _, isBossDebuff = UnitAura(unit, i) | |
if (dispel and dispel[dtype]) or (cfg.raidAuras and cfg.raidAuras[name]) then | |
if name then | |
self.Graphics.Auras:Show() | |
self.Graphics.AurasTexture:SetTexture(icon) | |
if beauty and self.Graphics.Auras:IsShown() then | |
local colour = DebuffTypeColor[dtype] or DebuffTypeColor.none | |
self.Graphics.Auras:SetBeautyBorderColor(colour.r, colour.g, colour.b) | |
end | |
else | |
print'successfully hidden!' | |
self.Graphics.Auras:Hide() | |
self.Graphics.AurasTexture:SetTexture'' | |
end | |
end | |
end | |
end | |
-- PvP objective watch | |
-- displays in name | |
local function pvp_Objectives(self, unitid) | |
local raidindex = GetRaidTargetIndex(unitid) | |
if UnitBuff(unitid, 'Alliance Flag') or UnitBuff(unitid, 'Horde Flag') or UnitBuff(unitid, 'Netherstorm Flag') or UnitBuff(unitid, 'Alliance Mine Cart') or UnitBuff(unitid, 'Horde Mine Cart') or UnitDebuff(unitid, 'Orb of Power') then | |
self.Graphics.Objective:Show() | |
self.Graphics.Text:Hide() | |
-- warsong gulch/twin peaks | |
if UnitBuff(unitid, 'Alliance Flag') then | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\allianceflag.tga') | |
elseif UnitBuff(unitid, 'Horde Flag') then | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\hordeflag.tga') | |
-- eye of the storm | |
elseif UnitBuff(unitid, 'Netherstorm Flag') then | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\neutralflag.tga') | |
-- deepwind gorge | |
elseif UnitBuff(unitid, 'Alliance Mine Cart') then | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\alliance_cart.tga') | |
elseif UnitBuff(unitid, 'Horde Mine Cart') then | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\horde_cart.tga') | |
-- temple of kotmogu | |
elseif UnitDebuff(unitid, 'Orb of Power') then -- figure out a way to make this work for alliance too at some point | |
self.Graphics.Objective:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\hordeflag.tga') | |
end | |
elseif raidindex then | |
self.Graphics.Text:SetText(ICON_LIST[raidindex]..'22|t') | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 8) | |
else | |
self.Graphics.Objective:Hide() | |
self.Graphics.Text:Show() | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
end | |
end | |
-- resurrect | |
local function inc_Ressurect(self, unit) | |
if UnitHasIncomingResurrection(unit) then | |
end | |
end | |
function UnitEventHandlers.UNIT_AURA(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
if unit==unitid then | |
pvp_Objectives(self, unitid) | |
raid_Auras(self, unitid) | |
inc_Ressurect(self, unit) | |
end | |
end | |
-- power events ------------------------------------------------------------------------- | |
function UnitEventHandlers.UNIT_DISPLAYPOWER(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
if unit==unitid then | |
self.Graphics.Power:Show() | |
self.Graphics.Power:SetMinMaxValues(0,UnitPowerMax(unitid)) | |
self.Graphics.Power:SetValue(UnitPower(unitid)) | |
local powerType, powerToken, altR, altG, altB = UnitPowerType(unitid) | |
local prefix = _G[powerToken]; | |
local info = PowerBarColor[powerToken] | |
if info then | |
self.Graphics.Power:SetStatusBarColor(info.r, info.g, info.b) | |
else | |
self.Graphics.Power:SetStatusBarColor(4/255, 78/255, 141/255) | |
end | |
end | |
end | |
function UnitEventHandlers.UNIT_POWER(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
if unit==unitid then | |
self.Graphics.Power:SetValue(UnitPower(unitid)) | |
end | |
end | |
-- dead/ghost/offline events ------------------------------------------------------------ | |
function UnitEventHandlers.PARTY_MEMBER_DISABLE(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
if unit==unitid then | |
if UnitIsDead(unitid) or UnitIsGhost(unitid) or not UnitIsConnected(unitid) then | |
self.Graphics.Health:SetAlpha(.7) | |
else | |
self.Graphics.Health:SetAlpha(1) | |
end | |
end | |
end | |
UnitEventHandlers.PARTY_MEMBER_ENABLE = UnitEventHandlers.PARTY_MEMBER_DISABLE | |
UnitEventHandlers.PLAYER_DEAD = UnitEventHandlers.PARTY_MEMBER_DISABLE | |
-- hp events ---------------------------------------------------------------------------- | |
function UnitEventHandlers.UNIT_HEALTH(self, eventunit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
local petunit, visibleunit | |
if unitid=='player' then | |
petunit = 'pet' | |
else | |
petunit = unitid..'pet' | |
end | |
if eventunit==unitid or eventunit==petunit then | |
if UnitHasVehicleUI(unitid) then | |
visibleunit = petunit | |
else | |
visibleunit = unitid | |
end | |
if UnitExists(visibleunit) then | |
-- sets hp bar | |
self.Graphics.Health:SetMinMaxValues(0,UnitHealthMax(visibleunit)) | |
self.Graphics.Health:SetValue(UnitHealth(visibleunit)) | |
end | |
end | |
end | |
UnitEventHandlers.UNIT_MAXHEALTH = UnitEventHandlers.UNIT_HEALTH | |
-- targeting events --------------------------------------------------------------------- | |
function UnitEventHandlers.PLAYER_TARGET_CHANGED(self) | |
local unitid = self.UnitID | |
if not unitid then return end | |
local visibleunit | |
if UnitHasVehicleUI(unitid) then | |
if unitid=='player' then | |
visibleunit = 'pet' | |
else | |
visibleunit = unitid..'pet' | |
end | |
else | |
visibleunit = unitid | |
end | |
if UnitIsUnit('target', visibleunit) then | |
self.Graphics.Overlay:Hide() | |
self.Graphics.Border:Show() | |
self.Graphics:SetBeautyBorderColor(255/255, 116/255, 119/255) | |
else | |
self.Graphics.Overlay:Show() | |
self.Graphics.Border:Hide() | |
self.Graphics:SetBeautyBorderColor(103/255, 103/255, 103/255) | |
end | |
end | |
-- threat events ------------------------------------------------------------------------ | |
function UnitEventHandlers.UNIT_THREAT_SITUATION_UPDATE(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
local unitaggro = UnitThreatSituation(unitid) | |
if unitaggro and unitaggro > 1 then | |
self.Graphics.Overlay:Hide() | |
self.Graphics.Aggro:Show() | |
self.Graphics:SetBeautyBorderColor(246/255, 21/255, 28/255) | |
else | |
self.Graphics.Overlay:Show() | |
self.Graphics.Aggro:Hide() | |
self.Graphics:SetBeautyBorderColor(103/255, 103/255, 103/255) | |
end | |
end | |
-- role & vehicle events ---------------------------------------------------------------- | |
function UnitEventHandlers.UPDATE_ROLE(self, unit) | |
local unitid = self.UnitID | |
local raidID = UnitInRaid(unitid) | |
if UnitInVehicle(unitid) and UnitHasVehicleUI(unitid) then | |
self.Graphics.roleIcon:SetTexture('Interface\\Vehicles\\UI-Vehicles-Raid-Icon') | |
self.Graphics.roleIcon:SetTexCoord(0, 1, 0, 1) | |
self.Graphics.roleIcon:Show() | |
else | |
local role = UnitGroupRolesAssigned(unitid) | |
if role=='TANK' then | |
self.Graphics.roleIcon:SetTexture('Interface\\Addons\\UnitFramesForModernists\\Art\\Tank.tga') | |
self.Graphics.roleIcon:SetSize(9, 9) | |
self.Graphics.roleIcon:Show() | |
elseif role=='HEALER' then | |
self.Graphics.roleIcon:SetTexture('Interface\\Addons\\UnitFramesForModernists\\Art\\Healer.tga') | |
self.Graphics.roleIcon:SetSize(8, 9) | |
self.Graphics.roleIcon:Show() | |
elseif role=='DAMAGER' then | |
-- we don't need to see DPS icons. it's unnecessary clutter. | |
self.Graphics.roleIcon:Hide() | |
else | |
self.Graphics.roleIcon:Hide() | |
end | |
end | |
end | |
-- raid icon events --------------------------------------------------------------------- | |
function UnitEventHandlers.RAID_TARGET_UPDATE(self) | |
local unitid = self.UnitID | |
if not unitid then return end | |
local RAID_TARGET_UPDATE = function(self, event) | |
local raidindex = GetRaidTargetIndex(self.unit) | |
if raidindex then | |
self.Graphics.Text:SetText(ICON_LIST[raidindex]..'22|t') | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 8) | |
else | |
self.Graphics.Text:SetText(TruncateName(UnitName(unitid))) | |
self.Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
end | |
end | |
end | |
-- re-engineer the portrait update event to update other stuff -------------------------- | |
function UnitEventHandlers.UNIT_PORTRAIT_UPDATE(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
UnitEventHandlers.UNIT_DISPLAYPOWER(self, unitid) | |
UnitEventHandlers.UNIT_AURA(self, unitid) | |
UnitEventHandlers.PARTY_MEMBER_DISABLE(self, unitid) | |
UnitEventHandlers.UNIT_HEALTH(self, unitid) | |
UnitEventHandlers.RAID_TARGET_UPDATE(self) | |
end | |
UnitEventHandlers.PLAYER_UNGHOST = UnitEventHandlers.UNIT_PORTRAIT_UPDATE | |
UnitEventHandlers.PLAYER_ALIVE = UnitEventHandlers.UNIT_PORTRAIT_UPDATE | |
-- InCombatLockdown() status event ------------------------------------------------------------------ | |
function UnitEventHandlers.UNIT_FLAGS(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
UnitEventHandlers.UNIT_AURA(self, unitid) | |
UnitEventHandlers.PARTY_MEMBER_DISABLE(self, unitid) | |
end | |
-- update when we enter or leave a vehicle | |
function UnitEventHandlers.UNIT_ENTERED_VEHICLE(self, unit) | |
OnChangeAttribute(self, 'unit') | |
if self.UnitID then | |
UpdateButton(self, self.UnitID) | |
end | |
end | |
UnitEventHandlers.UNIT_EXITED_VEHICLE = UnitEventHandlers.UNIT_ENTERED_VEHICLE | |
UnitEventHandlers.UNIT_PET = UnitEventHandlers.UNIT_ENTERED_VEHICLE | |
-- heal prediction event ---------------------------------------------------------------- | |
function UnitEventHandlers.UNIT_HEAL_PREDICTION(self, unit) | |
local unitid = self.UnitID | |
if not unitid then return end | |
if unit==unitid then | |
local incomingHeal = UnitGetIncomingHeals(unitid) or 0 | |
if incomingHeal > 0 then | |
incomingHeal = UnitHealth(unitid)+incomingHeal | |
end | |
self.Graphics.IncomingHeal:SetValue(incomingHeal) | |
end | |
end | |
-- hover colouring ---------------------------------------------------------------------- | |
-- need to create an event that allows a hierarchy for border colouring | |
-- something like: hover > target/threat > normal | |
--[[ local function HoverColour(self, hover) | |
if hover then | |
self.Graphics.Overlay:Hide() | |
self.Graphics.Hover:Show() | |
if beauty then | |
self.Graphics:SetBeautyBorderColor(99/255, 255/255, 4/255) | |
end | |
else | |
self.Graphics.Overlay:Show() | |
self.Graphics.Hover:Hide() | |
if beauty then | |
self.Graphics:SetBeautyBorderColor(103/255, 103/255, 103/255) | |
end | |
end | |
end]] | |
-- update the unitframe ----------------------------------------------------------------- | |
function UpdateButton(self, unitid) | |
self.Nextupdate = 0 | |
local Graphics = self.Graphics | |
local class = select(2, UnitClass(unitid)) or 'WARRIOR' | |
local color = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class] | |
local raidindex = GetRaidTargetIndex(unitid) | |
-- name | |
Graphics.Text:SetTextColor(1, .8, 0) | |
-- stop overwriting the raid icons | |
if raidindex then | |
Graphics.Text:SetText(ICON_LIST[raidindex]..'22|t') | |
Graphics.Text:SetFont(STANDARD_TEXT_FONT, 8) | |
else | |
Graphics.Text:SetText(TruncateName(UnitName(unitid))) | |
Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
end | |
-- hp | |
local maxhealth = UnitHealthMax(unitid) | |
Graphics.Health:SetStatusBarColor(color.r, color.g, color.b) | |
Graphics.Health:SetBackdropColor(0, 0, 0, 1) | |
Graphics.Health:SetMinMaxValues(0,maxhealth) | |
-- heal prediction | |
Graphics.IncomingHeal:SetStatusBarColor(0, .9, .1, .95) | |
Graphics.IncomingHeal:SetMinMaxValues(0,maxhealth) | |
-- power | |
Graphics.Power:SetBackdropColor(0, 0, 0, 1) | |
UnitEventHandlers.UNIT_DISPLAYPOWER(self, unitid) | |
UnitEventHandlers.UNIT_AURA(self, unitid) | |
UnitEventHandlers.PARTY_MEMBER_DISABLE(self, unitid) | |
UnitEventHandlers.UNIT_HEALTH(self, unitid) | |
UnitEventHandlers.UNIT_HEAL_PREDICTION(self, unitid) | |
--UnitEventHandlers.RAID_TARGET_UPDATE(self) | |
--role icons | |
role = UnitGroupRolesAssigned(unitid) | |
if role and role~='NONE' then | |
UnitEventHandlers.UPDATE_ROLE(self, unitid) | |
end | |
-- vehicle | |
if UnitHasVehicleUI(unitid) then | |
Graphics.Health:SetBackdropColor(0, 1, 0, .6) | |
else | |
Graphics.Health:SetBackdropColor(0, 0, 0, .6) | |
Graphics.Power:SetBackdropColor(0, 0, 0, .6) | |
end | |
end | |
-- event handlers ----------------------------------------------------------------------- | |
function SetHandlers(self) | |
self:SetScript('OnShow', OnShowButton) | |
self:SetScript('OnEvent', OnEvent) | |
self:SetScript('OnUpdate', PollOnUpdate) | |
for eventname, _ in pairs(UnitEventHandlers) do | |
self:RegisterEvent(eventname) | |
end | |
end | |
function OnShowButton(self) | |
if not InCombatLockdown() then | |
self:SetAttribute('*type1', 'target') | |
end | |
local unitid = self:GetAttribute('unit') | |
if unitid then | |
self.UnitID = unitid | |
UpdateButton(self, unitid) | |
end | |
end | |
function OnEvent(self, event, ...) | |
UnitEventHandlers[event](self, ...) | |
end | |
function OnChangeAttribute(self, attribute, value) | |
-- clique filter | |
if attribute=='_wrapentered' then return | |
elseif attribute=='unit' then | |
if not InCombatLockdown() then | |
self:SetAttribute('*type1', 'target') | |
-- vehicle | |
self:SetAttribute('toggleForVehicle', true) | |
end | |
-- clique | |
ClickCastFrames[self] = true | |
SetHandlers(self) | |
local unitid = self:GetAttribute('unit') | |
if unitid then | |
self.UnitID = unitid | |
UpdateButton(self, unitid) | |
end | |
end | |
end | |
-- build the unit frames ---------------------------------------------------------------- | |
function CreateUnitFrameArtwork(self) | |
local Graphics | |
if not InCombatLockdown() then | |
self:EnableMouse(true) | |
end | |
self.info = {} | |
-- create aura frame | |
self.AuraWatcher = CreateFrame('Frame', nil, self) | |
self.auraUpdateTime = 0 | |
self.rangeUpdateTime = 0 | |
-- base frame | |
self.Graphics = CreateFrame('Frame', nil, self) | |
Graphics = self.Graphics | |
Graphics:SetPoint('CENTER', self) | |
Graphics:SetFrameStrata('LOW') | |
Graphics:SetWidth(88) | |
Graphics:SetHeight(54) | |
if beauty then | |
Graphics:CreateBeautyBorder(17) | |
Graphics:SetBeautyBorderPadding(-13.5, -11, -13.5, -11, -13.5, -14, -13.5, -14) | |
Graphics:SetBeautyBorderDraw'OVERLAY' | |
Graphics:SetBeautyBorderColor(103/255, 103/255, 103/255) | |
end | |
-- hp | |
Graphics.Health = CreateFrame('StatusBar', nil, Graphics) | |
Graphics.Health:SetStatusBarTexture('Interface\\AddOns\\SkinningForModernists\\Statusbars\\statusbar.tga') | |
Graphics.Health:SetBackdrop({bgFile = 'Interface\\AddOns\\SkinningForModernists\\Statusbars\\statusbar.tga'}) | |
Graphics.Health:SetPoint('CENTER', 0, 6) | |
Graphics.Health:SetFrameLevel(Graphics:GetFrameLevel()-1) | |
Graphics.Health:SetWidth(52) | |
Graphics.Health:SetHeight(11) | |
-- heal prediction bar | |
Graphics.IncomingHeal = CreateFrame('StatusBar', nil, Graphics.Health) | |
Graphics.IncomingHeal:SetStatusBarTexture('Interface\\AddOns\\SkinningForModernists\\Statusbars\\statusbar.tga') | |
Graphics.IncomingHeal:SetFrameLevel(Graphics.Health:GetFrameLevel() - 1) | |
Graphics.IncomingHeal:SetAllPoints(Graphics.Health) | |
-- overlay anchor (To make layering easier) | |
Graphics.OverlayAnchor = CreateFrame('StatusBar', nil, Graphics.Health) | |
Graphics.OverlayAnchor:SetAllPoints() | |
Graphics.OverlayAnchor:SetFrameLevel(Graphics.Health:GetFrameLevel() + 1) | |
-- power | |
Graphics.Power = CreateFrame('StatusBar', nil, Graphics) | |
Graphics.Power:SetStatusBarTexture('Interface\\AddOns\\SkinningForModernists\\Statusbars\\statusbar.tga') | |
Graphics.Power:SetBackdrop({bgFile = 'Interface\\AddOns\\SkinningForModernists\\Statusbars\\statusbar.tga'}) | |
Graphics.Power:SetPoint('CENTER', 0, -5) | |
Graphics.Power:SetFrameLevel(Graphics:GetFrameLevel() - 1) | |
Graphics.Power:SetHeight(12) | |
Graphics.Power:SetWidth(54) | |
Graphics.Power:SetBackdropColor(0, 0, 0, .7) | |
-- name | |
Graphics.Text = Graphics.OverlayAnchor:CreateFontString(nil, 'OVERLAY') | |
Graphics.Text:SetFont(STANDARD_TEXT_FONT, 13) | |
Graphics.Text:SetShadowOffset(1.3, -1.3) | |
Graphics.Text:SetShadowColor(0, 0, 0, 1) | |
Graphics.Text:SetWidth(52) | |
Graphics.Text:SetHeight(12) | |
Graphics.Text:SetJustifyH('RIGHT') | |
Graphics.Text:SetPoint('BOTTOMRIGHT', Graphics.Health, 'TOPRIGHT', -1, 7) | |
Graphics.Text:SetShadowOffset(1, -1) | |
Graphics.Text:SetMaxLines(2) | |
-- pvp objective frame | |
Graphics.Objective = Graphics.OverlayAnchor:CreateTexture(nil, 'OVERLAY') | |
Graphics.Objective:SetPoint('BOTTOMRIGHT', Graphics.Health, 'TOPRIGHT', 0, 5) | |
Graphics.Objective:SetSize(14, 14) | |
Graphics.Objective:SetAlpha(1) | |
Graphics.Objective:Hide() | |
-- border art | |
Graphics.Overlay = Graphics.OverlayAnchor:CreateTexture(nil, 'ARTWORK', 4) | |
Graphics.Overlay:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\overlay.tga') | |
-- chop the image down because we stick to blizzards dumb power of 2 rule : thanx phanx | |
Graphics.Overlay:SetTexCoord(0, 88/128, 0, 54/64) | |
Graphics.Overlay:SetPoint('CENTER', Graphics, 0, 2) | |
Graphics.Overlay:SetWidth(58) | |
Graphics.Overlay:SetHeight(26) | |
Graphics.Overlay:SetVertexColor(.5, .48, .48) | |
-- raid icon | |
Graphics.RaidIcon = Graphics.OverlayAnchor:CreateTexture(nil, 'OVERLAY') | |
Graphics.RaidIcon:SetPoint('BOTTOMRIGHT', Graphics.Health, 'TOPRIGHT', 1, -3) | |
Graphics.RaidIcon:SetSize(10, 10) | |
Graphics.RaidIcon:Hide() | |
-- role icon | |
Graphics.roleIcon = Graphics.OverlayAnchor:CreateTexture(nil, 'OVERLAY') | |
Graphics.roleIcon:SetPoint('BOTTOMLEFT', Graphics.Health, 'TOPLEFT', 2, 8.7) | |
Graphics.roleIcon:SetSize(9, 9) | |
Graphics.roleIcon:Hide() | |
-- ready check | |
Graphics.readyCheckIcon = Graphics.OverlayAnchor:CreateTexture(nil, 'OVERLAY', 7) | |
Graphics.readyCheckIcon:SetPoint('CENTER', Graphics.Overlay, 'RIGHT', -14, 0) | |
Graphics.readyCheckIcon:SetSize(16, 16) | |
Graphics.readyCheckIcon:Hide() | |
-- targeted border art | |
Graphics.Border = Graphics:CreateTexture(nil, 'ARTWORK', 4) | |
Graphics.Border:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\overlay.tga') | |
Graphics.Border:SetTexCoord(0, 88/128, 0, 54/64) | |
Graphics.Border:SetPoint('CENTER', Graphics, 0, 2) | |
Graphics.Border:SetWidth(58) | |
Graphics.Border:SetHeight(26) | |
Graphics.Border:SetVertexColor(255/255, 116/255, 119/255) | |
Graphics.Border:Hide() | |
-- threat | |
Graphics.Aggro = Graphics:CreateTexture(nil, 'ARTWORK', 4) | |
Graphics.Aggro:SetTexture('Interface\\AddOns\\UnitFramesForModernists\\Art\\overlay.tga') | |
Graphics.Aggro:SetTexCoord(0, 88/128, 0, 54/64) | |
Graphics.Aggro:SetPoint('CENTER', Graphics, 0, 2) | |
Graphics.Aggro:SetWidth(58) | |
Graphics.Aggro:SetHeight(26) | |
Graphics.Aggro:SetVertexColor(246/255, 21/255, 28/255) | |
Graphics.Aggro:Hide() | |
-- aura | |
Graphics.Auras = CreateFrame('Frame', nil, Graphics) | |
Graphics.Auras:SetPoint('CENTER', 0, -3) | |
Graphics.Auras:SetSize(26, 26) | |
Graphics.Auras:SetAlpha(1) | |
Graphics.Auras:SetFrameLevel(6) | |
if beauty then | |
Graphics.Auras:CreateBeautyBorder(15) | |
Graphics.Auras:SetBeautyBorderPadding(1, 1, 1, 1, 1, 1, 1, 1) | |
Graphics.Auras:SetBeautyBorderDraw('OVERLAY', 7) | |
--Graphics.Auras:SetBeautyBorderColor(103/255, 103/255, 103/255) | |
end | |
Graphics.Auras:Hide() | |
-- aura texture | |
Graphics.AurasTexture = Graphics.Auras:CreateTexture(nil, 'ARTWORK', 8) | |
Graphics.AurasTexture:SetPoint'CENTER' | |
Graphics.AurasTexture:SetSize(25, 25) | |
Graphics.AurasTexture:SetAlpha(.7) | |
self:SetScript('OnAttributeChanged', OnChangeAttribute) | |
end | |
-- calls the unit frame artwork function; called by the secure config function | |
function CallArtworkFunction(self, frameName, ...) | |
local frame = _G[frameName] | |
CreateUnitFrameArtwork(frame) | |
frame:SetScript('OnEnter', ShowUnitTooltip) | |
frame:SetScript('OnLeave', HideUnitTooltip) | |
end | |
-- Initialization Function: set size and other properties of the unit button | |
-- Variables from addons are not accessible when this function is called. | |
SecureInitFunction = [[ | |
local header = self:GetParent() | |
header:CallMethod('CallArtworkFunction', self:GetName()) | |
self:SetWidth(88) | |
self:SetHeight(54) | |
]] | |
-- Creates the group header, which dynamically controls the creation of unit frames | |
function CreateGroupHeader() | |
local RaidGroupHeader = CreateFrame('Frame', 'RFForModernists_GroupHeader', UIParent, 'SecureGroupHeaderTemplate') | |
local HandleFrame = CreateFrame('Button', 'RFForModernists_Handle', RaidGroupHeader) | |
RaidGroupHeader:SetPoint('TOPLEFT', CompactRaidFrameManager, 'RIGHT', 0, 25) | |
RaidGroupHeader:SetMovable(true) | |
RaidGroupHeader:SetClampedToScreen(true) | |
-- RaidGroupHeader Frame Header | |
RaidGroupHeader:SetAttribute('template', 'SecureUnitButtonTemplate') | |
RaidGroupHeader:SetAttribute('templateType', 'Button') | |
RaidGroupHeader:SetAttribute('groupFilter', '1,2,3,4,5,6,7,8') | |
RaidGroupHeader:SetAttribute('showRaid', true) -- When true, the group header is shown when the player is in a raid. | |
RaidGroupHeader:SetAttribute('showParty', false) -- When true, the group header is shown when the player is in a party. This attribute doesnít imply showRaid but can work alongside it. | |
RaidGroupHeader:SetAttribute('showSolo', true) -- When true, the header is shown when the player is not in any group. This option implies showPlayer. | |
RaidGroupHeader:SetAttribute('showPlayer', false) -- When true, the header includes the player when not in a raid (normally, the player would not be visible in a party listing). | |
RaidGroupHeader:SetAttribute('point', 'TOP') -- The anchor point per row | |
RaidGroupHeader:SetAttribute('unitsPerColumn',5) | |
RaidGroupHeader:SetAttribute('columnSpacing', -22) | |
RaidGroupHeader:SetAttribute('xOffset', -22) | |
RaidGroupHeader:SetAttribute('yOffset', 7) | |
RaidGroupHeader:SetAttribute('maxColumns', 8) | |
RaidGroupHeader:SetAttribute('columnAnchorPoint','LEFT') -- The anchor point for each new column. A value of LEFT will cause the columns to grow to the right. | |
RaidGroupHeader.CallArtworkFunction = CallArtworkFunction -- This function is called from the init function | |
RaidGroupHeader:SetAttribute('initialConfigFunction', SecureInitFunction) -- Init function (Secure) | |
-- handle frame | |
HandleFrame:SetPoint('TOP', RaidGroupHeader, 0, -11) | |
HandleFrame:SetPoint('RIGHT', RaidGroupHeader, 8, 0) | |
HandleFrame:SetWidth(26) | |
HandleFrame:SetHeight(26) | |
local hfstring = HandleFrame:CreateFontString(nil, 'OVERLAY') | |
hfstring:SetFont(STANDARD_TEXT_FONT, 24, 'THINOUTLINE') | |
hfstring:SetShadowOffset(0,0) | |
hfstring:SetWidth(26) | |
hfstring:SetHeight(26) | |
hfstring:SetText('•') | |
hfstring:SetTextColor(245/255, 234/255, 55/255) | |
hfstring:SetJustifyH('RIGHT') | |
hfstring:SetPoint('RIGHT', HandleFrame, 'LEFT', 30, 0) | |
HandleFrame:SetClampedToScreen(true) | |
HandleFrame:RegisterForClicks('LeftButtonUp','RightButtonUp') | |
HandleFrame:Hide() | |
if not InCombatLockdown() then | |
HandleFrame:EnableMouse(false) -- /run RFForModernistsRaidFrames.HandleFrame:EnableMouse(false) -- to lock the frame, in game | |
end | |
HandleFrame:SetScript('OnClick', function(self, button) | |
if button=='RightButton' then | |
if not InCombatLockdown() then | |
HandleFrame:Hide() | |
HandleFrame:EnableMouse(false) | |
end | |
end | |
end) | |
HandleFrame:SetScript('OnMouseDown', function(self, button) | |
HandleFrame:SetAlpha(1) | |
if button=='LeftButton' then | |
RaidGroupHeader:StartMoving() | |
end | |
end) | |
HandleFrame:SetScript('OnMouseUp', function(self, button) | |
hfstring:SetTextColor(245/255, 234/255, 55/255) | |
RaidGroupHeader:StopMovingOrSizing() | |
end) | |
HandleFrame:SetScript('OnEnter', function(self) | |
hfstring:SetTextColor(56/255, 252/255, 185/255) | |
GameTooltip:SetOwner(HandleFrame, 'ANCHOR_LEFT') | |
GameTooltip:AddLine('Drag to move') | |
GameTooltip:AddLine('RightClick to hide anchor') | |
GameTooltip:Show() | |
end) | |
HandleFrame:SetScript('OnLeave', function(self) | |
hfstring:SetTextColor(245/255, 234/255, 55/255) | |
GameTooltip:Hide() | |
end) | |
RaidGroupHeader.HandleFrame = HandleFrame | |
RaidGroupHeader:Show() | |
return RaidGroupHeader | |
end | |
RFForModernists = CreateGroupHeader() | |
RFForModernists.TrackedAuras = TrackedAuras | |
-- slash commands ----------------------------------------------------------------------- | |
local function ToggleDraggingHandle(show) | |
if show==false then | |
RFForModernists_Handle:Hide() | |
else | |
RFForModernists_Handle:Show() | |
end | |
end | |
SlashCmdList['RaidFrame'] = function(msg) | |
if string.lower(msg)=='move' then | |
if RFForModernists_Handle:IsShown() then | |
if not InCombatLockdown() then | |
RFForModernists_Handle:Hide() | |
RFForModernists_Handle:EnableMouse(false) | |
end | |
DEFAULT_CHAT_FRAME:AddMessage('|cff01DFD7Raid Frames For Modernists|r - Anchor is now hidden.', 254/255, 193/255, 192/255) | |
else | |
if not InCombatLockdown() then | |
RFForModernists_Handle:Show() | |
RFForModernists_Handle:EnableMouse(true) | |
end | |
DEFAULT_CHAT_FRAME:AddMessage('|cff01DFD7Raid Frames For Modernists|r - Anchor is now shown.', 254/255, 193/255, 192/255) | |
end | |
elseif string.lower(msg)=='reset' then | |
RFForModernists_GroupHeader:ClearAllPoints() | |
RFForModernists_GroupHeader:SetPoint('TOPLEFT', CompactRaidFrameManager, 'RIGHT', 0, 3) | |
DEFAULT_CHAT_FRAME:AddMessage('|cff01DFD7Raid Frames For Modernists|r - Anchor position is now reset.', 254/255, 193/255, 192/255) | |
else | |
DEFAULT_CHAT_FRAME:AddMessage('|cff01DFD7Raid Frames For Modernists:|r ', 254/255, 193/255, 192/255) | |
if RFForModernists_Handle:IsShown() then | |
DEFAULT_CHAT_FRAME:AddMessage('|cffff9d65/raidframe move|r - Hide anchor.', 254/255, 193/255, 192/255) | |
else | |
DEFAULT_CHAT_FRAME:AddMessage('|cffff9d65/raidframe move|r - Show anchor.', 254/255, 193/255, 192/255) | |
end | |
DEFAULT_CHAT_FRAME:AddMessage('|cffff9d65/raidframe reset|r - Reset all positions.', 254/255, 193/255, 192/255) | |
end | |
end | |
SLASH_RaidFrame1 = '/raidframe' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment