Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --oUF_Senit 2012--
- --Gets Namespace
- local addon, ns = ...
- --Gets Config
- local config = ns.config
- --An Abbreviation
- local lib = CreateFrame("Frame")
- --FUNCTIONS--
- local backdrop = {
- bgFile = "Interface\\Addons\\oUF_Senit\\media\\backdrop",
- tile = true,
- tileSize = 32,
- insets = {
- left = -1,
- right = -1,
- top = -1,
- bottom = -1,
- },
- }
- local backdrop2 = {
- bgFile = "Interface\\Addons\\oUF_Senit\\media\\backdrop",
- tile = true,
- tileSize = 32,
- insets = {
- left = -1,
- right = -.6,
- top = -.6,
- bottom = -.7,
- },
- }
- lib.gen_backdrop = function(f)
- f:SetBackdrop(backdrop)
- f:SetBackdropColor(0, 0, 0, 1)
- end
- local updateTooltip = function(self)
- GameTooltip:SetUnitAura(self.parent:GetParent().unit, self:GetID(), self.filter)
- GameTooltip:Show()
- end
- local dropdown = CreateFrame("Frame", addon.."DropDown", UIParent, "UIDropDownMenuTemplate")
- UIDropDownMenu_Initialize(dropdown, function(self)
- local unit = self:GetParent().unit
- if not unit then return end
- local menu, name, id
- if UnitIsUnit(unit, "player") then
- menu = "SELF"
- elseif UnitIsUnit(unit, "vehicle") then
- menu = "VEHICLE"
- elseif UnitIsUnit(unit, "pet") then
- menu = "PET"
- elseif UnitIsPlayer(unit) then
- id = UnitInRaid(unit)
- if id then
- menu = "RAID_PLAYER"
- name = GetRaidRosterInfo(id)
- elseif UnitInParty(unit) then
- menu = "PARTY"
- else
- menu = "PLAYER"
- end
- else
- menu = "TARGET"
- name = RAID_TARGET_ICON
- end
- if menu then
- UnitPopup_ShowMenu(self, menu, unit, name, id)
- end
- end, "MENU")
- lib.menu = function(self)
- dropdown:SetParent(self)
- ToggleDropDownMenu(1, nil, dropdown, "cursor", 0, 0)
- end
- do
- for k,v in pairs(UnitPopupMenus) do
- for x,y in pairs(UnitPopupMenus[k]) do
- if y == "SET_FOCUS" then
- table.remove(UnitPopupMenus[k],x)
- elseif y == "CLEAR_FOCUS" then
- table.remove(UnitPopupMenus[k],x)
- end
- end
- end
- end
- lib.gen_fontstring = function(f, name, size, outline)
- local fs = f:CreateFontString(nil, "OVERLAY")
- fs:SetFont(name, size, outline)
- return fs
- end
- lib.gen_hpbar = function(f)
- --Statusbar
- local s = CreateFrame("StatusBar", nil, f)
- s:SetStatusBarTexture(config.statusbar_texture)
- s:SetBackdrop(backdrop)
- s:SetBackdropColor(0, 0, 0, 1)
- s:SetHeight(f.height)
- s:SetWidth(f.width)
- s:SetPoint("CENTER",0,0)
- --background (["name" [, "layer" [, "inherits" [, sublevel]]]])
- local b = s:CreateTexture(nil, "BACKGROUND", _, 1)
- b:SetTexture(config.statusbar_texture)
- b:SetAllPoints(s)
- f.Health = s
- f.Health.bg = b
- end
- lib.tar_fontstrings = function(f)
- local name, hpval
- --health/name text strings
- if not f.hidename then
- name = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- name:SetPoint("LEFT", f.Health, "LEFT", 19, 1)
- name:SetJustifyH("LEFT")
- end
- hpval = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- hpval:SetPoint("RIGHT", f.Health, "RIGHT", -19, 1)
- hpval.frequentUpdates = 0.1
- hpperc = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- hpperc:SetPoint("RIGHT", f.Health, "RIGHT", -19, 1)
- hpperc.frequentUpdates = 0.1
- if f.hidename then
- hpval:SetJustifyH("CENTER")
- hpval:SetPoint("LEFT", f.Health, "LEFT", 2, 0)
- else
- --this will make the name go "..." when its to long
- name:SetPoint("RIGHT", hpval, "LEFT", -5, 0)
- hpval:SetJustifyH("RIGHT")
- if f.nametag then
- f:Tag(name, f.nametag)
- else
- f:Tag(name, "[name]")
- end
- end
- if f.hptag then
- f:Tag(hpval, f.hptag)
- else
- f:Tag(hpval, "[senit:hpdefault] : [senit:hpperc]")
- end
- end
- lib.pla_fontstrings = function(f)
- local ppdefault
- ppdefault = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- ppdefault:SetPoint("CENTER", f.Health, "CENTER", -2, 0)
- ppdefault.frequentUpdates = 0.1
- if f.hidename then
- ppdefault:SetJustifyH("CENTER")
- ppdefault:SetPoint("LEFT", f.Health, "LEFT", 2, 0)
- else
- ppdefault:SetAlpha(0)
- ppdefault:SetJustifyH("CENTER")
- if f.nametag then
- f:Tag(name, f.nametag)
- else
- f:Tag(name, "[name]")
- end
- end
- if f.hptag then
- f:Tag(ppdefault, f.hptag)
- else
- f:Tag(ppdefault, "[senit:ppdefault]")
- end
- f:SetScript("OnEnter", function(self) ppdefault:SetAlpha(1); UnitFrame_OnEnter(self) end)
- f:SetScript("OnLeave", function(self) ppdefault:SetAlpha(0); UnitFrame_OnLeave(self) end)
- end
- lib.cps_fontstrings = function(f)
- local name = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- name:SetPoint("CENTER", f.Health, "CENTER", 80, 1)
- name:SetJustifyH("CENTER")
- f:Tag(name, "[myComboPoints]")
- end
- lib.tot_fontstrings = function(f)
- local name = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- name:SetPoint("LEFT", f.Health, _, 2, 1)
- name:SetPoint("RIGHT", f.Health, _, -2, 1)
- name:SetJustifyH("CENTER")
- f:Tag(name, "[name]")
- end
- lib.raid_fontstrings = function(f)
- local name = lib.gen_fontstring(f.Health, config.font, 8, "OUTLINEMONOCHROME")
- name:SetPoint("LEFT", f.Health, _, 2, 0)
- name:SetPoint("RIGHT", f.Health, _, -2, 0)
- name:SetJustifyH("CENTER")
- f:Tag(name, "[unitcolor][name]")
- end
- lib.gen_ppbar = function(f)
- --Statusbar
- local s = CreateFrame("StatusBar", nil, f)
- s:SetStatusBarTexture(config.statusbar_texture)
- s:SetFrameLevel(0)
- s:SetHeight(f.height/4)
- s:SetWidth(f.width/1.2)
- s:SetPoint("TOP",f,"BOTTOM",0,1)
- s:SetBackdrop(backdrop)
- s:SetBackdropColor(0, 0, 0, 1)
- local b = s:CreateTexture(nil, "BACKGROUND", _, 1)
- b:SetTexture(config.statusbar_texture)
- b:SetAllPoints(s)
- f.Power = s
- f.Power.bg = b
- end
- lib.gen_ppbar2 = function(f)
- --Statusbar
- local s = CreateFrame("StatusBar", nil, f)
- s:SetStatusBarTexture(config.statusbar_texture)
- s:SetHeight(f.height/8)
- s:SetWidth(f.width)
- --s:SetPoint("TOP",f,"BOTTOM",0,-1)
- s:SetBackdrop(backdrop)
- s:SetBackdropColor(0, 0, 0, 1)
- local b = s:CreateTexture(nil, "BACKGROUND", _, 1)
- b:SetTexture(config.statusbar_texture)
- b:SetAllPoints(s)
- f.Power = s
- f.Power.bg = b
- end
- lib.gen_castbar = function(f)
- local s = CreateFrame("StatusBar", "oUF_SenitCastbar")
- s:SetHeight(f.height/3)
- s:SetWidth(f.width/1.41)
- s:SetBackdrop(backdrop2)
- s:SetBackdropColor(0, 0, 0, 1)
- if f.mystyle == "player" then
- s:SetPoint("CENTER",UIParent,0,0)
- elseif f.mystyle == "target" then
- s:SetPoint("CENTER",UIParent,0,-20)
- s:SetParent(target)
- else
- s:SetPoint("BOTTOM",f,"TOP",0,-25)
- end
- s:SetStatusBarTexture(config.statusbar_texture)
- s:SetStatusBarColor(20/255, 20/255, 20/255, 1)
- local b = s:CreateTexture(nil, "BACKGROUND", _, 1)
- b:SetTexture(config.statusbar_texture)
- b:SetAllPoints(s)
- b:SetVertexColor(100/255, 100/255, 100/255)
- if f.mystyle == "player" then
- local z = s:CreateTexture(nil,"OVERLAY")
- z:SetTexture(config.statusbar_texture)
- z:SetVertexColor(250/255,30/255,30/255,.6)
- z:SetPoint("TOPRIGHT")
- z:SetPoint("BOTTOMRIGHT")
- s:SetFrameLevel(10)
- s.SafeZone = z
- end
- local txt = lib.gen_fontstring(s, config.font, 6, "OUTLINE MONOCHROME")
- txt:SetPoint("LEFT", 2, -5)
- txt:SetJustifyH("LEFT")
- --time
- local t = lib.gen_fontstring(s, config.font, 6, "OUTLINE MONOCHROME")
- t:SetPoint("RIGHT", -2, -5)
- txt:SetPoint("RIGHT", t, "LEFT", -5, 0)
- f.Castbar = s
- f.Castbar.Text = txt
- f.Castbar.Time = t
- f.Castbar.bg = b
- end
- lib.PostUpdateRaidFrame = function(Health, unit, min, max)
- local disconnnected = not UnitIsConnected(unit)
- local dead = UnitIsDead(unit)
- local ghost = UnitIsGhost(unit)
- if disconnnected or dead or ghost then
- Health:SetValue(max)
- if(disconnnected) then
- Health:SetStatusBarColor(0,0,0,0.6)
- elseif(ghost) then
- Health:SetStatusBarColor(0,0,0,0.6)
- elseif(dead) then
- Health:SetStatusBarColor(100/255,100/255,100/255,1)
- end
- else
- Health:SetValue(min)
- if(unit == 'vehicle') then
- Health:SetStatusBarColor(22/255, 106/255, 44/255)
- end
- end
- end
- --[[
- lib.PostCreateIcon = function(self, button)
- button.remaining = lib.gen_fontstring(button, config.font, 8, "OUTLINEMONOCHROME")
- button.remaining:SetPoint("CENTER", 1, 0)
- button.cd:SetReverse(true)
- button.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9)
- button.icon:SetDrawLayer("BACKGROUND")
- --Count
- button.count:ClearAllPoints()
- button.count:SetFont(config.font, 8, "OUTLINEMONOCHROME")
- button.count:SetJustifyH("RIGHT")
- button.count:SetPoint("TOPRIGHT", button, "TOPRIGHT", 0, 0)
- button.count:SetTextColor(1,1,1)
- --Helper
- local h = CreateFrame("Frame", nil, button)
- h:SetFrameLevel(0)
- h:SetPoint("TOPLEFT", -0, 0)
- h:SetPoint("BOTTOMRIGHT", 0, -0)
- lib.gen_backdrop(h)
- end--]]
- --[[
- local myPostCreateIcon = function(self, button)
- self.showDebuffType = true
- self.disableCooldown = true
- button.cd.noOCC = true
- button.cd.noCooldownCount = true
- button.icon:SetTexCoord(.07, .93, .07, .93)
- button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
- button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 0, 0)
- button.overlay:SetTexture(border)
- button.overlay:SetTexCoord(0,1,0,1)
- button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
- button.time = lib.gen_fontstring(button, config.font, 8, "OUTLINEMONOCHROME")
- button.time:SetPoint("CENTER", button, 2, 0)
- button.time:SetJustifyH('CENTER')
- button.time:SetVertexColor(1,1,1)
- button.count = lib.gen_fontstring(button, config.font, 8, "OUTLINEMONOCHROME")
- button.count:ClearAllPoints()
- button.count:SetPoint("BOTTOMRIGHT", button, 7, -5)
- button.count:SetVertexColor(1,1,1)
- local h = CreateFrame("Frame", nil, button)
- h:SetFrameLevel(0)
- h:SetPoint("TOPLEFT",-5,5)
- h:SetPoint("BOTTOMRIGHT",5,-5)
- lib.gen_backdrop(h)
- end--]]
- local formatTime = function(s)
- local day, hour, minute = 86400, 3600, 60
- if s >= day then
- return format("%dd", floor(s/day + 0.5)), s % day
- elseif s >= hour then
- return format("%dh", floor(s/hour + 0.5)), s % hour
- elseif s >= minute then
- return format("%dm", floor(s/minute + 0.5)), s % minute
- elseif s >= minute / 1200 then
- return floor(s), (s * 100 - floor(s * 100))/100
- end
- return format("%.1f", s), (s * 100 - floor(s * 100))/100
- end
- local setTimer = function (self, elapsed)
- if self.timeLeft then
- self.elapsed = (self.elapsed or 0) + elapsed
- if self.elapsed >= 0.1 then
- if not self.first then
- self.timeLeft = self.timeLeft - self.elapsed
- else
- self.timeLeft = self.timeLeft - GetTime()
- self.first = false
- end
- if self.timeLeft > 0 then
- local time = formatTime(self.timeLeft)
- self.time:SetText(time)
- if self.timeLeft < 5 then
- self.time:SetTextColor(1, .2, 0)
- else
- self.time:SetTextColor(1, 1, 1)
- end
- else
- self.time:Hide()
- self:SetScript("OnUpdate", nil)
- end
- self.elapsed = 0
- end
- end
- end
- local postCreateIcon = function(element, button)
- local diffPos = 0
- local self = element:GetParent()
- if self.mystyle == "target" then diffPos = 1 end
- element.disableCooldown = true
- button.cd.noOCC = true
- button.cd.noCooldownCount = true
- local h = CreateFrame("Frame", nil, button)
- h:SetFrameLevel(0)
- h:SetPoint("TOPLEFT",0,0)
- h:SetPoint("BOTTOMRIGHT",0,0)
- lib.gen_backdrop(h)
- local time = lib.gen_fontstring(button, config.font, 8, "OUTLINEMONOCHROME")
- time:SetPoint("CENTER", button, "CENTER", 1, 0)
- time:SetJustifyH("CENTER")
- time:SetVertexColor(1,1,1)
- button.time = time
- local count = lib.gen_fontstring(button, config.font, 8, "OUTLINEMONOCHROME")
- count:SetPoint("CENTER", button, "BOTTOMRIGHT", 0, 3)
- count:SetJustifyH("RIGHT")
- button.count = count
- button.UpdateTooltip = updateTooltip
- button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
- button.icon:SetDrawLayer("ARTWORK")
- end
- local postUpdateIcon = function(element, unit, button, index)
- local _, _, _, _, _, duration, expirationTime, unitCaster, _ = UnitAura(unit, index, button.filter)
- if duration and duration > 0 then
- button.time:Show()
- button.timeLeft = expirationTime
- button:SetScript("OnUpdate", setTimer)
- else
- button.time:Hide()
- button.timeLeft = math.huge
- button:SetScript("OnUpdate", nil)
- end
- -- [[ Desaturate non-Player Debuffs ]] --
- if(button.debuff) then
- if(unit == "target") then
- if (unitCaster == "player" or unitCaster == "vehicle") then
- button.icon:SetDesaturated(false)
- elseif(not UnitPlayerControlled(unit)) then -- If Unit is Player Controlled don"t desaturate debuffs
- button:SetBackdropColor(0, 0, 0)
- button.overlay:SetVertexColor(0.3, 0.3, 0.3)
- button.icon:SetDesaturated(true)
- end
- end
- end
- button:SetScript('OnMouseUp', function(self, mouseButton)
- if mouseButton == 'RightButton' then
- CancelUnitBuff('player', index)
- end end)
- button.first = true
- end
- --AURAS--
- local SortAuras = function(a, b)
- if (a and b and a.timeLeft and b.timeLeft) then
- return a.timeLeft > b.timeLeft
- end
- end
- local PreSetPosition = function(Auras)
- table.sort(Auras, SortAuras)
- end
- lib.playBuffs = function(f)
- b = CreateFrame("Frame", nil, f)
- b.size = 30
- if f.mystyle == "target" then
- b.num = 40
- elseif f.mystyle == "player" then
- b.num = 10
- b.onlyShowPlayer = true
- else
- b.num = 5
- end
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 500)
- b.initialAnchor = "TOPRIGHT"
- b["growth-x"] = "LEFT"
- b["growth-y"] = "DOWN"
- b.PostCreateIcon = postCreateIcon
- b.PostUpdateIcon = postUpdateIcon
- f.Buffs = b
- f.Buffs.PreSetPosition = PreSetPosition
- BuffFrame:UnregisterEvent("UNIT_AURA")
- BuffFrame:Hide()
- TemporaryEnchantFrame:Hide()
- end
- lib.createBuffs = function(f)
- b = CreateFrame("Frame", nil, f)
- b.size = 18.8
- if f.mystyle == "target" then
- b.num = 8
- elseif f.mystyle == "player" then
- b.num = 8
- b.onlyShowPlayer = true
- else
- b.num = 8
- end
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 20, 5)
- b.initialAnchor = "BOTTOMLEFT"
- b["growth-x"] = "RIGHT"
- b["growth-y"] = "UP"
- b.PostCreateIcon = postCreateIcon
- b.PostUpdateIcon = postUpdateIcon
- f.Buffs = b
- --f.Buffs.PreSetPosition = PreSetPosition
- end
- lib.createDebuffs = function(f)
- b = CreateFrame("Frame", nil, f)
- b.size = 20
- if f.mystyle == "target" then
- b.num = 40
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 0, -5)
- b.initialAnchor = "TOPLEFT"
- b["growth-x"] = "RIGHT"
- b["growth-y"] = "DOWN"
- elseif f.mystyle == "player" then
- b.num = 10
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 5)
- b.initialAnchor = "BOTTOMLEFT"
- b["growth-x"] = "RIGHT"
- b["growth-y"] = "UP"
- else
- b.num = 5
- end
- b.PostCreateIcon = lib.PostCreateIcon
- f.Debuffs = b
- end
- lib.customfilter = function(Buffs, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID)
- if config.auras[spellID] then
- return true
- end
- end
- lib.debufftracker = function(f)
- b = CreateFrame("Frame", nil, f)
- b.size = 30
- if f.mystyle == "target" then
- b.num = 40
- elseif f.mystyle == "player" then
- b.num = 10
- b.onlyShowPlayer = true
- else
- b.num = 5
- end
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("BOTTOMRIGHT", f, "TOPRIGHT", 0, 50)
- b.initialAnchor = "BOTTOMRIGHT"
- b["growth-x"] = "LEFT"
- b["growth-y"] = "UP"
- b.PostCreateIcon = postCreateIcon
- b.PostUpdateIcon = postUpdateIcon
- f.Debuffs = b
- --f.Debuffs.PreSetPosition = PreSetPosition
- b.CustomFilter = lib.customfilter
- end
- lib.bufftracker = function(f)
- b = CreateFrame("Frame", nil, f)
- b.size = 30
- if f.mystyle == "target" then
- b.num = 40
- elseif f.mystyle == "player" then
- b.num = 10
- b.onlyShowPlayer = true
- else
- b.num = 5
- end
- b.spacing = 5
- b.onlyShowPlayer = false
- b:SetHeight((b.size+b.spacing)*4)
- b:SetWidth(f.width)
- b:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, 15)
- b.initialAnchor = "BOTTOMLEFT"
- b["growth-x"] = "RIGHT"
- b["growth-y"] = "UP"
- b.PostCreateIcon = postCreateIcon
- b.PostUpdateIcon = postUpdateIcon
- f.Buffs = b
- --f.Buffs.PreSetPosition = PreSetPosition
- b.CustomFilter = lib.customfilter
- --[[
- local t = lib.gen_fontstring(b, config.font, 6, "OUTLINE MONOCHROME")
- t:SetPoint("CENTER", 0, 0)
- f.Buffs = b
- f.Buffs.Time = t
- --]]
- end
- --SPECIAL POWER--
- ns.lib = lib
Advertisement
Add Comment
Please, Sign In to add comment