Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function CreateBar(unit, uf, name, db) -- create status bars for health or power
- local f = uf[name]
- local ishp = (name == "hpbar")
- if db.hide or (name == "mpbar" and UnitPowerMax(unit) > 0) then
- if f then
- f:Hide()
- Stuf:RegisterElementRefresh(uf, name, (ishp and "healthelements") or "powerelements", nil)
- end
- return
- end
- if not f then
- f = Stuf:CreateBase(unit, uf, name, db)
- f.bg = f:CreateTexture(nil, "BACKGROUND")
- f.bg:SetAllPoints(f)
- f.barbase = CreateFrame("Frame", nil, uf)
- f.bar = f:CreateTexture(nil, "ARTWORK")
- uf.refreshfuncs[name] = UpdateStatusBar
- uf.refreshfuncs["barcolors"] = UpdateBarColors
- else
- f:Show()
- end
- if db.fade and not f.barfade then
- f.barfade = f:CreateTexture(nil, "BORDER")
- end
- if ishp then
- if db.inc then
- f.incbar = f.incbar or f:CreateTexture(nil, "ARTWORK")
- f.incbar:SetAlpha(1)
- Stuf:AddEvent("UNIT_HEAL_PREDICTION", IncomingHeal)
- elseif f.incbar then
- f.incbar:SetAlpha(0)
- end
- end
- -- five second rule mana tick
- if unit == "player" and not ishp and not db.hidemanatick and CLS ~= "HUNTER" and CLS ~= "ROGUE" and CLS ~= "WARRIOR" and CLS ~= "DEATHKNIGHT" then
- if not f.spark then
- local spark = f:CreateTexture(nil, "OVERLAY")
- spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
- spark:SetBlendMode("ADD")
- f.spark = spark
- local lastmana, fivestart, recentcast = 1000000, 0, 0
- local function SparkOnUpdate(this, a1)
- local frac = (GetTime() - fivestart) * 0.2062
- if frac > 1 then
- f.barbase:SetScript("OnUpdate", nil)
- spark:Hide()
- else
- spark:SetAlpha(frac > 0.1 and frac or 0.1)
- spark:SetSparkPoint(f.bvalue * frac)
- end
- end
- local function manatick(unit)
- if unit ~= "player" or not showtick then return end
- if not uf or uf.hidden then return end
- if uf.cache.powertype ~= 0 then
- spark:Hide()
- f.barbase:SetScript("OnUpdate", nil)
- return
- end
- local current = UnitPower(unit)
- if current < lastmana and GetTime() - recentcast < 0.6 then
- fivestart = recentcast
- recentcast = 0
- spark:Show()
- f.barbase:SetScript("OnUpdate", SparkOnUpdate)
- end
- lastmana = current
- end
- Stuf:AddEvent("UNIT_SPELLCAST_SUCCEEDED", function(unit)
- if unit == "player" and showtick then
- recentcast = GetTime()
- end
- end)
- Stuf:AddEvent("UNIT_POWER", manatick)
- uf.refreshfuncs["manatick"] = manatick
- Stuf:RegisterElementRefresh(uf, "manatick", "powercolorelements", true)
- end
- showtick = true
- elseif f.spark and db.hidemanatick then
- f.spark:Hide()
- showtick = nil
- end
- UpdateBarLook(unit, uf, f, db)
- if f.spark then
- f.spark:Hide()
- if db.vertical then
- if db.reverse then
- f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "TOP", 0, -value) end
- else
- f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "BOTTOM", 0, value) end
- end
- else
- if db.reverse then
- f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "RIGHT", -value, 0) end
- else
- f.spark.SetSparkPoint = function(this, value) this:SetPoint("CENTER", f.barbase, "LEFT", value, 0) end
- end
- end
- end
- local barcm, bgcm = db.barcolormethod or "blah", db.bgcolormethod or "blah"
- f.barth = (barcm == "hpthreshold" or barcm == "hpthresholddark") and barcm or nil
- f.bgth = (bgcm == "hpthreshold" or bgcm == "hpthresholddark") and bgcm or nil
- if not ishp and (strmatch(barcm, "power") or strmatch(bgcm, "power")) then
- f.colorchanges = true
- Stuf:RegisterElementRefresh(uf, "barcolors", "powercolorelements", true)
- end
- if strmatch(barcm, "reaction") or strmatch(bgcm, "reaction") then
- f.colorchanges = true
- Stuf:RegisterElementRefresh(uf, "barcolors", "reactionelements", true)
- end
- Stuf:RegisterElementRefresh(uf, name, ishp and "healthelements" or "powerelements", true)
- if Stuf.inworld then
- UpdateStatusBar(unit, uf, f, true, uf.cache[ishp and "frachp" or "fracmp"])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement