diff --git a/ElvUI_SLE/modules/autorelease.lua b/ElvUI_SLE/modules/autorelease.lua new file mode 100644 index 0000000..0c045ce --- /dev/null +++ b/ElvUI_SLE/modules/autorelease.lua @@ -0,0 +1,50 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +-- local AR = E:NewModule('SLE_AutoRelease', 'AceHook-3.0', 'AceEvent-3.0'); +local AR = E:GetModule('SLE_AutoRelease') +local myclass = E.myclass +local IsInInstance = IsInInstance +local soulstone = GetSpellInfo(20707) +local UnitLevel = UnitLevel +local GetSpellCooldown = GetSpellCooldown +local level = 0 +local cd +local GetTime = GetTime +local RepopMe = RepopMe + +local function Check(level, cd) + if ((myclass ~= "SHAMAN") and not (soulstone and UnitBuff("player", soulstone))) then + RepopMe() + elseif myclass == "SHAMAN" and (level < 32 or cd > 0) then + RepopMe() + end +end + +function AR:Releasing() + local inInstance, instanceType = IsInInstance() + if myclass == "SHAMAN" then + level = UnitLevel("player") + local start, duration = GetSpellCooldown(20608) + if duration == nil then duration = 0 end + cd = (start + duration - GetTime()) + end + if (inInstance and (instanceType == "pvp")) then + if E.db.sle.pvpautorelease then Check(level, cd) end + end + + -- auto resurrection for world PvP area...when active + if E.db.sle.pvpautorelease then + for index = 1, GetNumWorldPVPAreas() do + local _, localizedName, isActive = GetWorldPVPAreaInfo(index) + if (GetRealZoneText() == localizedName and isActive) then Check(level, cd) end + end + end +end + +function AR:Initialize() + ShowUIPanel(GhostFrame) + E:CreateMover(GhostFrame, "GhostFrameMover", L["Ghost Frame"], nil, nil, nil, "ALL,S&L,S&L MISC") + HideUIPanel(GhostFrame) + self:RegisterEvent("PLAYER_DEAD", "Releasing"); +end + +-- E:RegisterModule(AR:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/backgrounds.lua b/ElvUI_SLE/modules/backgrounds.lua new file mode 100644 index 0000000..6c1036d --- /dev/null +++ b/ElvUI_SLE/modules/backgrounds.lua @@ -0,0 +1,118 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +-- local BG = E:NewModule('SLE_BackGrounds', 'AceHook-3.0', 'AceEvent-3.0'); +local BG = E:GetModule('SLE_BackGrounds'); + +local BGb, BGl, BGr, BGa, Fr + +--Frames setup +function BG:FramesCreate() + BGb = CreateFrame('Frame', "BottomBG", E.UIParent); + BGl = CreateFrame('Frame', "LeftBG", E.UIParent); + BGr = CreateFrame('Frame', "RightBG", E.UIParent); + BGa = CreateFrame('Frame', "ActionBG", E.UIParent); + + Fr = { + BottomBG = {BGb,"bottom"}, + LeftBG = {BGl,"left"}, + RightBG = {BGr,"right"}, + ActionBG = {BGa,"action"}, + } + + for _,v in pairs(Fr) do + v[1]:SetFrameLevel(v[1]:GetFrameLevel() - 1) + v[1]:SetScript("OnShow", function() v[1]:SetFrameStrata('BACKGROUND') end) + v[1].tex = v[1]:CreateTexture(nil, 'OVERLAY') + v[1]:Hide() + end + + BGb:EnableMouse(true) --Maybe add an option to actually allow change this click catching? + BGb.tex:SetAlpha(0.5) + --Also the problem. As long as bottom bg can be transparent it's no good in keeping fixed transparency for the texture. + --Maybe add an option to change this from using Elv's trnsparency to additional user-set one? + BGl.tex:SetAlpha(E.db.general.backdropfadecolor.a - 0.7 > 0 and E.db.general.backdropfadecolor.a - 0.7 or 0.5) + + BGr.tex:SetAlpha(E.db.general.backdropfadecolor.a - 0.7 > 0 and E.db.general.backdropfadecolor.a - 0.7 or 0.5) + + BGa:EnableMouse(true) + BGa.tex:SetAlpha(E.db.general.backdropfadecolor.a - 0.7 > 0 and E.db.general.backdropfadecolor.a - 0.7 or 0.5) +end + +--Frames Size +function BG:FramesSize() + if not BGb then return end + local db = E.db.sle.backgrounds + for _,v in pairs(Fr) do + v[1]:SetSize(db[v[2]].width, db[v[2]].height) + end +end + +--Frames points +function BG:FramesPositions() + if not BGb then return end + BGb:Point("BOTTOM", E.UIParent, "BOTTOM", 0, 21); + BGl:Point("BOTTOMRIGHT", E.UIParent, "BOTTOM", -(E.screenwidth/4 + 32)/2 - 1, 21); + BGr:Point("BOTTOMLEFT", E.UIParent, "BOTTOM", (E.screenwidth/4 + 32)/2 + 1, 21); + BGa:Point("BOTTOM", E.UIParent, "BOTTOM", 0, E.screenheight/6 + 9); +end + +--Updating textures +function BG:UpdateTex() + if not BGb then return end + local db = E.db.sle.backgrounds + for _,v in pairs(Fr) do + v[1].tex:Point('TOPLEFT', v[1], 'TOPLEFT', 2, -2) + v[1].tex:Point('BOTTOMRIGHT', v[1], 'BOTTOMRIGHT', -2, 2) + v[1].tex:SetTexture(db[v[2]].texture) + end +end + +--Visibility / Enable check +function BG:FramesVisibility() + if not BGb then return end + local db = E.db.sle.backgrounds + for _,v in pairs(Fr) do + if db[v[2]].enabled then + v[1]:Show() + else + v[1]:Hide() + end + end +end + +function BG:UpdateFrames() + if not BGb then return end + local db = E.db.sle.backgrounds + for _,v in pairs(Fr) do + v[1]:SetTemplate(db[v[2]].template, true) + end + BG:FramesSize() + BG:FramesVisibility() + BG:UpdateTex() +end + +function BG:RegisterHide() + if not BGb then return end + local db = E.db.sle.backgrounds + for k,v in pairs(Fr) do + if db[v[2]].pethide then + E.FrameLocks[k] = true + else + E.FrameLocks[k] = nil + end + end +end + +function BG:Initialize() + if not E.private.sle.backgrounds then return end + BG:FramesCreate() + BG:FramesPositions() + BG:UpdateFrames() + BG:RegisterHide() + + E:CreateMover(BottomBG, "BottomBG_Mover", L["Bottom BG"], nil, nil, nil, "S&L,S&L BG") + E:CreateMover(LeftBG, "LeftBG_Mover", L["Left BG"], nil, nil, nil, "S&L,S&L BG") + E:CreateMover(RightBG, "RightBG_Mover", L["Right BG"], nil, nil, nil, "S&L,S&L BG") + E:CreateMover(ActionBG, "ActionBG_Mover", L["Actionbar BG"], nil, nil, nil, "S&L,S&L BG") +end + +-- E:RegisterModule(BG:GetName()) \ No newline at end of file