Last active
March 24, 2021 18:20
-
-
Save L3n1n/fc30706536ee5419924b228787e04066 to your computer and use it in GitHub Desktop.
Eclipsor for Shadowlands
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
if select(2, UnitClass("player")) ~= "DRUID" then | |
return | |
end | |
local power, solarEclipse, lunarEclipse | |
-- Default settings of the addon | |
local defaultsettings = { | |
colors = { | |
BarLunarNormal = {r = 0, g = 0.4, b = 1}, | |
BarLunarEclipse = {r = 0, g = 0.6, b = 1}, | |
BarSolarNormal = {r = 1, g = 0.8, b = 0.2}, | |
BarSolarEclipse = {r = 1, g = 1, b = 0}, | |
Frame = {r = 1, g = 1, b = 0.6}, | |
Font = {r = 1, g = 1, b = 0} | |
}, | |
alpha = { | |
BarLunarNormal = 1, | |
BarLunarEclipse = 1, | |
BarSolarNormal = 1, | |
BarSolarEclipse = 1, | |
Frame = 0.75, | |
LunarEclipse = 1, | |
SolarEclipse = 1, | |
ShootingStars = 1, | |
Font = 1 | |
}, | |
x = UIParent:GetWidth()/2, | |
y = UIParent:GetHeight()/2, | |
scale = 1, | |
locked = 0, | |
option1 = 0, | |
option2 = 0 | |
} | |
local E = CreateFrame("Frame",nil,UIParent) | |
E:SetFrameStrata("MEDIUM") | |
E:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end) | |
E:SetScript("OnUpdate", function(self) E:update() end) | |
E:SetMovable(true) | |
E:EnableMouse(true) | |
E:SetScale(1) | |
E:RegisterForDrag("LeftButton") | |
E:RegisterEvent("ADDON_LOADED") | |
E:RegisterEvent("UNIT_POWER_FREQUENT") | |
E:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") | |
E:RegisterEvent("UPDATE_SHAPESHIFT_FORM") | |
E:RegisterEvent("PLAYER_REGEN_DISABLED") | |
E:RegisterEvent("PLAYER_REGEN_ENABLED") | |
E:RegisterEvent("SPELL_ACTIVATION_OVERLAY_SHOW") | |
E:RegisterEvent("PLAYER_ALIVE") | |
E:SetScript("OnDragStart", function(self) self:StartMoving() end) | |
E:SetScript("OnDragStop", function(self) | |
self:StopMovingOrSizing() | |
E_Saved.x = self:GetLeft()+self:GetWidth()/2 | |
E_Saved.y = self:GetBottom()+self:GetHeight()/2 | |
self:ClearAllPoints() | |
self:SetPoint("CENTER",UIParent,"BOTTOMLEFT",E_Saved.x,E_Saved.y) | |
end); | |
-- Frame texture | |
E.kol = E:CreateTexture(nil, "ARTWORK") | |
E.kol:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\frame.tga") | |
E.kol:SetPoint("CENTER",0,-12) | |
E.kol:SetWidth(512) | |
E.kol:SetHeight(256) | |
E:SetPoint("CENTER",0,0) | |
-- Current lunar/solar power | |
E.valuetext = E:CreateFontString(nil,"ARTWORK","GameFontNormalSmall") | |
E.valuetext:SetTextColor(1,1,0,1) | |
E.valuetext:SetPoint("CENTER",0,30) | |
E.valuetext:SetText("0") | |
E.valuetext:SetTextHeight(30) | |
E.stars = {} | |
----------------------- | |
-- Utility Functions -- | |
----------------------- | |
function E:eclipse() | |
if power == nil then | |
power=UnitPower("player", SPELL_POWER_ECLIPSE) | |
end | |
local lunar = 0 | |
local solar = 0 | |
local tempPower = abs(power) | |
local moon = AuraUtil.FindAuraByName(GetSpellInfo(48518), "player") | |
local sun = AuraUtil.FindAuraByName(GetSpellInfo(48517), "player") | |
if moon and moon ~= nil then | |
E.valuetext:SetText("< "..tempPower.." ") | |
-- lunar = power | |
local _, _, _, _, duration, timeExpired = AuraUtil.FindAuraByName(GetSpellInfo(48518), "player") | |
lunar = (timeExpired - GetTime())/duration*100 | |
elseif sun and sun ~= nil then | |
E.valuetext:SetText(" "..tempPower.." >") | |
-- solar = power | |
local _, _, _, _, duration, timeExpired = AuraUtil.FindAuraByName(GetSpellInfo(48517), "player") | |
solar = (timeExpired - GetTime())/duration*100 | |
else | |
E.valuetext:SetText(power) | |
end | |
--outer ring | |
local outer_radius = 256 | |
--inner ring | |
local inner_radius = 223 | |
--angle | |
local angle = 0 | |
if(lunar > 0)then | |
angle=lunar*0.45 | |
end | |
if(solar > 0)then | |
angle=solar*0.45 | |
end | |
local Arad = math.rad(angle) | |
local ULx,ULy, LLx,LLy, URx,URy, LRx,LRy | |
local Nx = 0 | |
local Ny = 60 | |
local Ix = inner_radius * math.sin(Arad) | |
local Iy = outer_radius - (inner_radius * math.cos(Arad)) | |
local Ox = outer_radius * math.sin(Arad) | |
local Oy = outer_radius - (outer_radius * math.cos(Arad)) | |
local IxCoord = Ix / outer_radius | |
local IyCoord = Iy / outer_radius | |
local OxCoord = Ox / outer_radius | |
local OyCoord = Oy / outer_radius | |
-- DEFAULT_CHAT_FRAME:AddMessage("BOTTOMRIGHTY "..(outer_radius-Iy)) | |
if(lunar==0 and solar==0)then | |
if(E.t1~=nil and E.t11~=nil and E.t12~=nil)then | |
E.t1:Hide() | |
E.t11:Hide() | |
E.t12:Hide() | |
end | |
if(E.t0~=nil and E.t01~=nil and E.t02~=nil)then | |
E.t0:Hide() | |
E.t01:Hide() | |
E.t02:Hide() | |
end | |
end | |
if(lunar>0)then | |
if(E.t1~=nil and E.t11~=nil and E.t12~=nil)then | |
E.t1:Hide() | |
E.t11:Hide() | |
E.t12:Hide() | |
end | |
if(E.t0==nil)then | |
E.t0 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t0:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Ring.tga") | |
if(E_Saved.colors~=nil)then | |
if(lunarEclipse==1)then | |
E.t0:SetVertexColor(E_Saved.colors.BarLunarEclipse.r, E_Saved.colors.BarLunarEclipse.g, E_Saved.colors.BarLunarEclipse.b) | |
E.t0:SetAlpha(E_Saved.alpha.BarLunarEclipse) | |
else | |
E.t0:SetVertexColor(E_Saved.colors.BarLunarNormal.r, E_Saved.colors.BarLunarNormal.g, E_Saved.colors.BarLunarNormal.b) | |
E.t0:SetAlpha(E_Saved.alpha.BarLunarNormal) | |
end | |
end | |
E.t0:SetPoint("TOPRIGHT",E.kol,"CENTER",Nx,Ny) | |
E.t0:SetWidth(Ix) | |
E.t0:SetHeight(Iy) | |
E.t0:SetTexCoord(1-IxCoord,0, 1-IxCoord,IyCoord, 1,0, 1,IyCoord) | |
E.t0:Show() | |
if(E.t01==nil)then | |
E.t01 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t01:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Ring.tga") | |
if(E_Saved.colors~=nil)then | |
if(lunarEclipse==1)then | |
E.t01:SetVertexColor(E_Saved.colors.BarLunarEclipse.r, E_Saved.colors.BarLunarEclipse.g, E_Saved.colors.BarLunarEclipse.b) | |
E.t01:SetAlpha(E_Saved.alpha.BarLunarEclipse) | |
else | |
E.t01:SetVertexColor(E_Saved.colors.BarLunarNormal.r, E_Saved.colors.BarLunarNormal.g, E_Saved.colors.BarLunarNormal.b) | |
E.t01:SetAlpha(E_Saved.alpha.BarLunarNormal) | |
end | |
end | |
E.t01:SetPoint("TOPRIGHT",E.kol,"CENTER",-Ix,Ny) | |
E.t01:SetWidth(Ox-Ix) | |
E.t01:SetHeight(Oy) | |
E.t01:SetTexCoord(1-OxCoord,0, 1-OxCoord,OyCoord, 1-IxCoord,0, 1-IxCoord,OyCoord) | |
E.t01:Show() | |
if(E.t02==nil)then | |
E.t02 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t02:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Slice1.tga") | |
if(E_Saved.colors~=nil)then | |
if(lunarEclipse==1)then | |
E.t02:SetVertexColor(E_Saved.colors.BarLunarEclipse.r, E_Saved.colors.BarLunarEclipse.g, E_Saved.colors.BarLunarEclipse.b) | |
E.t02:SetAlpha(E_Saved.alpha.BarLunarEclipse) | |
else | |
E.t02:SetAlpha(E_Saved.alpha.BarLunarNormal) | |
E.t02:SetVertexColor(E_Saved.colors.BarLunarNormal.r, E_Saved.colors.BarLunarNormal.g, E_Saved.colors.BarLunarNormal.b) | |
end | |
end | |
E.t02:SetPoint("TOPRIGHT",E.kol,"CENTER",Nx-Ix,Ny-Oy) | |
E.t02:SetWidth(Ox-Ix) | |
E.t02:SetHeight(Iy-Oy) | |
E.t02:Show() | |
end | |
if(solar>0)then | |
if(E.t0~=nil and E.t01~=nil and E.t02~=nil)then | |
E.t0:Hide() | |
E.t01:Hide() | |
E.t02:Hide() | |
end | |
if(E.t1==nil)then | |
E.t1 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t1:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Ring.tga") | |
if(E_Saved.colors~=nil)then | |
if(solarEclipse==1)then | |
E.t1:SetVertexColor(E_Saved.colors.BarSolarEclipse.r, E_Saved.colors.BarSolarEclipse.g, E_Saved.colors.BarSolarEclipse.b) | |
E.t1:SetAlpha(E_Saved.alpha.BarSolarEclipse) | |
else | |
E.t1:SetVertexColor(E_Saved.colors.BarSolarNormal.r, E_Saved.colors.BarSolarNormal.g, E_Saved.colors.BarSolarNormal.b) | |
E.t1:SetAlpha(E_Saved.alpha.BarSolarNormal) | |
end | |
end | |
E.t1:SetPoint("TOPLEFT",E.kol,"CENTER",-Nx,Ny) | |
E.t1:SetWidth(Ix) | |
E.t1:SetHeight(Iy) | |
E.t1:SetTexCoord(1,0, 1,IyCoord, 1-IxCoord,0, 1-IxCoord,IyCoord) | |
E.t1:Show() | |
if(E.t11==nil)then | |
E.t11 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t11:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Ring.tga") | |
if(E_Saved.colors~=nil)then | |
if(solarEclipse==1)then | |
E.t11:SetVertexColor(E_Saved.colors.BarSolarEclipse.r, E_Saved.colors.BarSolarEclipse.g, E_Saved.colors.BarSolarEclipse.b) | |
E.t11:SetAlpha(E_Saved.alpha.BarSolarEclipse) | |
else | |
E.t11:SetVertexColor(E_Saved.colors.BarSolarNormal.r, E_Saved.colors.BarSolarNormal.g, E_Saved.colors.BarSolarNormal.b) | |
E.t11:SetAlpha(E_Saved.alpha.BarSolarNormal) | |
end | |
end | |
E.t11:SetPoint("TOPLEFT",E.kol,"CENTER",Ix,Ny) | |
E.t11:SetWidth(Ox-Ix) | |
E.t11:SetHeight(Oy) | |
E.t11:SetTexCoord(1-IxCoord,0, 1-IxCoord,OyCoord, 1-OxCoord,0, 1-OxCoord,OyCoord) | |
E.t11:Show() | |
if(E.t12==nil)then | |
E.t12 = E:CreateTexture(nil, "BORDER") | |
end | |
E.t12:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Slice1.tga") | |
if(E_Saved.colors~=nil)then | |
if(solarEclipse==1)then | |
E.t12:SetVertexColor(E_Saved.colors.BarSolarEclipse.r, E_Saved.colors.BarSolarEclipse.g, E_Saved.colors.BarSolarEclipse.b) | |
E.t12:SetAlpha(E_Saved.alpha.BarSolarEclipse) | |
else | |
E.t12:SetVertexColor(E_Saved.colors.BarSolarNormal.r, E_Saved.colors.BarSolarNormal.g, E_Saved.colors.BarSolarNormal.b) | |
E.t12:SetAlpha(E_Saved.alpha.BarSolarNormal) | |
end | |
end | |
E.t12:SetPoint("TOPLEFT",E.kol,"CENTER",-Nx+Ix,Ny-Oy) | |
E.t12:SetWidth(Ox-Ix) | |
E.t12:SetHeight(Iy-Oy) | |
E.t12:SetTexCoord(1,0,1,1,0,0,0,1) | |
E.t12:Show() | |
end | |
end | |
--determine the visibility based on combat/moonkin form | |
function E:comply() | |
local flag1 = false | |
local flag2 = false | |
if GetSpecialization() == 1 then | |
local combat = UnitAffectingCombat("player") | |
if(E_Saved.option1 == 1)then | |
if(combat == true)then | |
flag1 = true | |
else | |
flag1 = false | |
end | |
else | |
flag1 = true | |
end | |
--DEFAULT_CHAT_FRAME:AddMessage("flag1 je nyni "..tostring(UnitBuff("player", "Moonkin Form") )) | |
if(E_Saved.option2 == 1)then | |
if(UnitBuff("player", "Moonkin Form")~=nil)then | |
flag2 = true | |
else | |
flag2 = false | |
end | |
else | |
flag2 = true | |
end | |
--DEFAULT_CHAT_FRAME:AddMessage("flag2 je nyni "..flag2) | |
if(flag1 and flag2)then | |
E:Show() | |
else | |
E:Hide() | |
end | |
end | |
end | |
function E:display() | |
if (not E_Saved) then | |
E_Saved = defaultsettings | |
else | |
for i,v in pairs(defaultsettings) do | |
if (not E_Saved[i]) then | |
E_Saved[i] = v | |
end | |
end | |
end | |
E:Show() | |
E:SetWidth(370) | |
E:SetHeight(105) | |
E:SetAlpha(1) | |
E:SetPoint("CENTER",UIParent,"BOTTOMLEFT",E_Saved.x,E_Saved.y); | |
E:UnregisterEvent("ADDON_LOADED"); | |
--E.lunecl = E:CreateTexture(nil,"ARTWORK") | |
E.lunecl:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Eclipse_Moon.blp") | |
E.lunecl:SetPoint("CENTER",-180,35) | |
if(E_Saved.alpha~=nil)then | |
E.lunecl:SetAlpha(E_Saved.alpha.LunarEclipse) | |
end | |
E.lunecl:SetWidth(80) | |
E.lunecl:SetHeight(80) | |
--E.sunecl = E:CreateTexture(nil,"ARTWORK") | |
E.sunecl:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\Eclipse_Sun.blp") | |
E.sunecl:SetPoint("CENTER",180,35) | |
if(E_Saved.alpha~=nil)then | |
E.sunecl:SetAlpha(E_Saved.alpha.SolarEclipse) | |
end | |
E.sunecl:SetWidth(80) | |
E.sunecl:SetHeight(80) | |
if(E_Saved.alpha~=nil)then | |
E.kol:SetAlpha(E_Saved.alpha.Frame) | |
E.kol:SetVertexColor(E_Saved.colors.Frame.r, E_Saved.colors.Frame.g, E_Saved.colors.Frame.b) | |
end | |
if(E_Saved.scale~=nil)then | |
E:SetScale(E_Saved.scale) | |
end | |
if(E_Saved.locked==1)then | |
E:EnableMouse(false) | |
else | |
E:EnableMouse(true) | |
end | |
E.valuetext:SetTextColor(E_Saved.colors.Font.r, E_Saved.colors.Font.g, E_Saved.colors.Font.b, E_Saved.alpha.Font) | |
E:comply() | |
end | |
function E:Talents() | |
local _, class = UnitClass("player") | |
if (GetSpecialization() == 1 and class=="DRUID") then | |
E:display() | |
E:eclipse() | |
end | |
end | |
-------------------- | |
-- Event Handlers -- | |
-------------------- | |
function E:createStar(star) | |
E.location = { | |
[1]={ x=-35,y=12 }, | |
[2]={ x=5,y=17 }, | |
[3]={ x=45,y=12 } | |
} | |
E.stars[star] = E:CreateTexture(nil,"ARTWORK") | |
E.stars[star]:SetTexture("Interface\\AddOns\\Eclipsor\\gfx\\stack.tga") | |
E.stars[star]:SetPoint("BOTTOM",E.location[star].x,E.location[star].y) | |
if(E_Saved~=nil)then | |
if(E_Saved.alpha~=nil)then | |
E.stars[star]:SetAlpha(E_Saved.alpha.ShootingStars) | |
end | |
end | |
E.stars[star]:SetWidth(50) | |
E.stars[star]:SetHeight(50) | |
E.stars[star]:Show() | |
end | |
function E:update() | |
if(E.stars[1]==nil)then E:createStar(1) end | |
if(E.stars[2]==nil)then E:createStar(2) end | |
if(E.stars[3]==nil)then E:createStar(3) end | |
-- Is Lunar Peak active? | |
auraName = GetSpellInfo(48518) | |
name = AuraUtil.FindAuraByName(auraName, "player") | |
if(name~=nil)then | |
E.lunecl:Show() | |
lunarEclipse=1 | |
else | |
if(E.lunecl~=nil)then | |
E.lunecl:Hide() | |
end | |
lunarEclipse=0 | |
end | |
-- Is Solar Peak active? | |
auraName = GetSpellInfo(48517) | |
name = AuraUtil.FindAuraByName(auraName, "player") | |
if(name~=nil)then | |
E.sunecl:Show() | |
solarEclipse=1 | |
else | |
if(E.sunecl~=nil)then | |
E.sunecl:Hide() | |
solarEclipse=0 | |
end | |
end | |
local power = UnitPower("player", SPELL_POWER_ECLIPSE) | |
local auraName = GetSpellInfo(78674) | |
local costTable = GetSpellPowerCost(auraName) | |
local cost | |
for _, costInfo in pairs(costTable) do | |
if costInfo.name == "LUNAR_POWER" then | |
cost = costInfo.cost | |
break | |
end | |
end | |
E.stars[1]:Hide(); | |
E.stars[2]:Hide(); | |
E.stars[3]:Hide(); | |
local stacks = math.floor(power / cost) | |
for i=1, stacks do | |
E.stars[i]:Show() | |
E.stars[i]:SetAlpha(E_Saved.alpha.ShootingStars) | |
E.stars[i]:SetTexCoord(0, 1, 0, 1) | |
E.stars[i]:SetHeight(50) | |
end | |
if stacks ~= 3 then | |
local index=stacks+1 | |
E.stars[index]:Show() | |
E.stars[index]:SetTexCoord(0, 1, 0, 1) | |
E.stars[index]:SetHeight(50) | |
E.stars[index]:SetAlpha(E_Saved.alpha.ShootingStars/2) | |
end | |
--DEFAULT_CHAT_FRAME:AddMessage((GetTime()-cd)/dur) | |
local maxpower = UnitPowerMax("player", SPELL_POWER_ECLIPSE) | |
if power == maxpower then | |
E:eclipse() | |
end | |
end | |
function E:ADDON_LOADED(addon) | |
solarEclipse=0 | |
lunarEclipse=0 | |
local _, class = UnitClass("player") | |
if (class == "DRUID" and addon == "Eclipsor") then | |
DEFAULT_CHAT_FRAME:AddMessage("Eclipsor Loaded") | |
E.lunecl = E:CreateTexture(nil,"ARTWORK") | |
E.sunecl = E:CreateTexture(nil,"ARTWORK") | |
E:Talents() | |
end | |
end | |
function E:ACTIVE_TALENT_GROUP_CHANGED(self,...) | |
local _, class = UnitClass("player") | |
if (GetSpecialization() == 1 and class=="DRUID") then | |
if (not E_Saved) then | |
E_Saved = defaultsettings | |
else | |
for i,v in pairs(defaultsettings) do | |
if (not E_Saved[i]) then | |
E_Saved[i] = v | |
end | |
end | |
end | |
power=0 | |
E:display() | |
E:eclipse() | |
else | |
E:Hide() | |
end | |
end | |
function E:UPDATE_SHAPESHIFT_FORM() | |
E:comply() | |
end | |
function E:PLAYER_ALIVE() | |
E:Talents() | |
end | |
function E:PLAYER_REGEN_DISABLED() | |
E:comply() | |
end | |
function E:PLAYER_REGEN_ENABLED() | |
E:comply() | |
end | |
function E:UNIT_POWER_FREQUENT(arg1,arg2,...) | |
power = UnitPower("player", SPELL_POWER_ECLIPSE) | |
E:eclipse() | |
end | |
function E:SPELL_ACTIVATION_OVERLAY_SHOW(arg1,...) | |
local origin = SpellActivationOverlay_ShowAllOverlays | |
SpellActivationOverlay_ShowAllOverlays = function(...) | |
local self, spellID = ... | |
if(spellID==93400 or spellID==93430 or spellID==93431)then | |
return | |
else | |
return origin(...) | |
end | |
end | |
end | |
------------------- | |
-- Options Frame -- | |
------------------- | |
SlashCmdList["ECLIPSOR"] = function(msg) | |
if (msg=="lock")then | |
E:EnableMouse(false) | |
E_Saved.locked=1 | |
else | |
if (msg=="unlock")then | |
E:EnableMouse(true) | |
E_Saved.locked=0 | |
else | |
if (not E_OptionsFrame) then | |
E:CreateOptionsFrame() | |
end | |
--if (E:IsVisible())then | |
E_OptionsFrame:Show() | |
--end | |
end | |
end | |
end | |
SLASH_ECLIPSOR1 = "/eclipsor" | |
function E:CreateOptionsFrame() | |
local sliders = { | |
{ text = "Eclipsed lunar bar", name = "BarLunarEclipse", value = E_Saved.alpha.BarLunarEclipse, min = 0, max = 1, step = 0.1 }, | |
{ text = "Lunar bar", name = "BarLunarNormal", value = E_Saved.alpha.BarLunarNormal, min = 0, max = 1, step = 0.1 }, | |
{ text = "Eclipsed solar bar", name = "BarSolarEclipse", value = E_Saved.alpha.BarSolarEclipse, min = 0, max = 1, step = 0.1 }, | |
{ text = "Solar bar", name = "BarSolarNormal", value = E_Saved.alpha.BarSolarNormal, min = 0, max = 1, step = 0.1 }, | |
{ text = "Frame", name = "Frame", value = E_Saved.alpha.Frame, min = 0, max = 1, step = 0.1, update = function(val) E.kol:SetAlpha(val) end }, | |
{ text = "Font", name = "Font", value = E_Saved.alpha.Font, min = 0, max = 1, step = 0.1, update = function(val) local r,g,b,a=E.valuetext:GetTextColor() E.valuetext:SetTextColor(r,g,b,val) end }, | |
{ text = "Lunar Eclipse icon", name = "LunarEclipse", value = E_Saved.alpha.LunarEclipse, min = 0, max = 1, step = 0.1, update = function(val) E.lunecl:SetAlpha(val) end }, | |
{ text = "Solar Eclipse icon", name = "SolarEclipse", value = E_Saved.alpha.SolarEclipse, min = 0, max = 1, step = 0.1, update = function(val) E.sunecl:SetAlpha(val) end }, | |
{ text = "Shooting Stars icon", name = "ShootingStars", value = E_Saved.alpha.ShootingStars, min = 0, max = 1, step = 0.1, update = function(val) E.stars:SetAlpha(val) end }, | |
} | |
local colorButtons = { | |
{ name = "BTN_BLE", value = E_Saved.colors.BarLunarEclipse, func = function() end}, | |
{ name = "BTN_BLN", value = E_Saved.colors.BarLunarNormal, func = function() end}, | |
{ name = "BTN_BSE", value = E_Saved.colors.BarSolarEclipse, func = function() end}, | |
{ name = "BTN_BSN", value = E_Saved.colors.BarSolarNormal, func = function() end}, | |
{ name = "BTN_FRAME", value = E_Saved.colors.Frame, func = function() E.kol:SetVertexColor(E_Saved.colors.Frame.r, E_Saved.colors.Frame.g, E_Saved.colors.Frame.b) end}, | |
{ name = "BTN_FONT", value = E_Saved.colors.Font, func = function() E.valuetext:SetTextColor(E_Saved.colors.Font.r, E_Saved.colors.Font.g, E_Saved.colors.Font.b, E_Saved.alpha.Font) end} | |
} | |
local buttons = { | |
{ text = "Close", func = function(self) E_OptionsFrame:Hide() end }, | |
{ text = "Deafault", func = function(self) E_Saved=defaultsettings E.display() E.eclipse() end } | |
} | |
------------------- | |
-- Options Frame -- | |
------------------- | |
local optionsframe = CreateFrame("frame","E_OptionsFrame") | |
E.optionsframe=optionsframe | |
optionsframe:SetBackdrop({ | |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", | |
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", | |
tile=u1, tileSize=32, edgeSize=32, | |
insets={left=11, right=12, top=12, bottom=11} | |
}) | |
optionsframe:SetWidth(450) | |
optionsframe:SetHeight(500) | |
optionsframe:SetPoint("CENTER",UIParent) | |
optionsframe:EnableMouse(true) | |
optionsframe:SetMovable(true) | |
optionsframe:RegisterForDrag("LeftButton") | |
--------------- | |
-- First TAB -- | |
--------------- | |
local myTabPage1 = CreateFrame("frame","myTabPage1",optionsframe) | |
myTabPage1:SetFrameStrata("FULLSCREEN_DIALOG") | |
myTabPage1:SetBackdrop({ | |
edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", | |
tile=u1, tileSize=16, edgeSize=16, | |
insets={left=11, right=12, top=12, bottom=11} | |
}) | |
myTabPage1:Show() | |
myTabPage1:SetHeight(375) | |
myTabPage1:SetWidth(410) | |
myTabPage1:SetPoint("BOTTOM", optionsframe, 0, 55) | |
--== CONTENT ==-- | |
local scaleSlider = { text = "UI Scale", name = "Scale", value = E_Saved.scale, min = 0.1, max = 2, step = 0.05, update = function(val) | |
local tmp = E_Saved.scale | |
if(abs(val-tmp)>0.04)then | |
E:SetScale(val) | |
E_Saved.x = E_Saved.x/(val/tmp) | |
E_Saved.y = E_Saved.y/(val/tmp) | |
E:SetPoint("CENTER",UIParent,"BOTTOMLEFT",E_Saved.x,E_Saved.y) | |
--DEFAULT_CHAT_FRAME:AddMessage(val.."/"..tmp.."="..(val/tmp)) | |
E_Saved.scale=val | |
end | |
end } | |
local generalSettings = { | |
{text="Hide when out of combat", checked=E_Saved.option1, update=function(val) | |
if(val==true)then | |
E_Saved.option1=1 | |
else | |
E_Saved.option1=0 | |
end | |
end}, | |
{text="Hide when out of moonkin form", checked=E_Saved.option2, update=function(val) | |
if(val==true)then | |
E_Saved.option2=1 | |
else | |
E_Saved.option2=0 | |
end | |
end}, | |
} | |
local slider = CreateFrame("slider", "E_ScaleSlider", myTabPage1, "OptionsSliderTemplate") | |
slider:SetPoint("TOP",myTabPage1,"TOP",0,-22) | |
local text = slider:CreateFontString(nil,"ARTWORK","GameFontNormalSmall") | |
text:SetPoint("LEFT",slider,"LEFT",-140,0) | |
text:SetText(scaleSlider.text) | |
text:SetTextHeight(12) | |
local valuetext = slider:CreateFontString(nil,"ARTWORK","GameFontNormalSmall") | |
valuetext:SetPoint("TOP",slider,"BOTTOM",50,-1) | |
valuetext:SetText(format("%.2f",scaleSlider.value)) | |
--getglobal("E_OptionsFrameSlider"..i.."Text"):SetText(v.text) | |
getglobal("E_ScaleSliderLow"):SetText(scaleSlider.min) | |
getglobal("E_ScaleSliderHigh"):SetText(scaleSlider.max) | |
slider:SetMinMaxValues(scaleSlider.min,scaleSlider.max) | |
slider:SetValueStep(scaleSlider.step) | |
slider:SetValue(scaleSlider.value) | |
slider:SetScale(0.9) | |
slider:SetScript("OnValueChanged",function() | |
local val=slider:GetValue() | |
valuetext:SetText(format("%.2f",val)) | |
if(scaleSlider.update~=nil)then | |
scaleSlider.update(val) | |
else | |
E:eclipse() | |
end | |
end) | |
for i,v in pairs(generalSettings) do | |
local myCheckButton = CreateFrame("CheckButton", "E_OptionsCheckButton"..i, myTabPage1, "ChatConfigCheckButtonTemplate"); | |
if (i == 1) then | |
myCheckButton:SetPoint("TOP",myTabPage1,"TOPLEFT",20,-44) | |
else | |
myCheckButton:SetPoint("TOP",getglobal("E_OptionsCheckButton"..(i-1)),"BOTTOM",0,-22) | |
end | |
if (v.checked == 1)then | |
myCheckButton:SetChecked(true) | |
else | |
myCheckButton:SetChecked(false) | |
end | |
getglobal(myCheckButton:GetName() .. 'Text'):SetText(" "..v.text); | |
myCheckButton:SetScript("OnClick", | |
function() | |
v.update(myCheckButton:GetChecked()) | |
E:comply() | |
end | |
) | |
end | |
---------------- | |
-- Second TAB -- | |
---------------- | |
local myTabPage2 = CreateFrame("frame","myTabPage2",optionsframe) | |
myTabPage2:SetFrameStrata("FULLSCREEN_DIALOG") | |
myTabPage2:SetBackdrop({ | |
edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", | |
tile=u1, tileSize=16, edgeSize=16, | |
insets={left=11, right=12, top=12, bottom=11} | |
}) | |
myTabPage2:Hide() | |
myTabPage2:SetHeight(375) | |
myTabPage2:SetWidth(410) | |
myTabPage2:SetPoint("BOTTOM", optionsframe, 0, 55) | |
--== CONTENT ==-- | |
for i,v in pairs(sliders) do | |
local slider = CreateFrame("slider", "E_OptionsFrameSlider"..i, myTabPage2, "OptionsSliderTemplate") | |
if (i == 1) then | |
slider:SetPoint("TOP",myTabPage2,"TOP",0,-22) | |
else | |
slider:SetPoint("TOP",getglobal("E_OptionsFrameSlider"..(i-1)),"BOTTOM",0,-22) | |
end | |
local text = slider:CreateFontString(nil,"ARTWORK","GameFontNormalSmall") | |
text:SetPoint("LEFT",slider,"LEFT",-140,0) | |
text:SetText(v.text) | |
text:SetTextHeight(12) | |
local valuetext = slider:CreateFontString(nil,"ARTWORK","GameFontNormalSmall") | |
valuetext:SetPoint("TOP",slider,"BOTTOM",50,-1) | |
valuetext:SetText(format("%.2f",v.value)) | |
--getglobal("E_OptionsFrameSlider"..i.."Text"):SetText(v.text) | |
getglobal("E_OptionsFrameSlider"..i.."Low"):SetText(v.min) | |
getglobal("E_OptionsFrameSlider"..i.."High"):SetText(v.max) | |
slider:SetMinMaxValues(v.min,v.max) | |
slider:SetValueStep(v.step) | |
slider:SetValue(v.value) | |
slider:SetScale(0.9) | |
slider:SetScript("OnValueChanged",function() | |
local val=slider:GetValue() | |
E_Saved.alpha[v.name]=val | |
valuetext:SetText(format("%.2f",val)) | |
if(v.update~=nil)then | |
v.update(val) | |
else | |
E:eclipse() | |
end | |
end) | |
if(i<=#colorButtons)then | |
local but = CreateFrame("Frame",colorButtons[i].name,myTabPage2) | |
but:SetFrameStrata("FULLSCREEN_DIALOG") | |
but:Show() | |
but:SetWidth(50) | |
but:SetHeight(20) | |
but:SetAlpha(1) | |
but:SetPoint("CENTER",slider,"TOPRIGHT",70,-10) | |
but:EnableMouse(true) | |
but.tex = but:CreateTexture(nil,"ARTWORK") | |
but.tex:SetTexture(colorButtons[i].value.r,colorButtons[i].value.g,colorButtons[i].value.b) | |
but.tex:SetPoint("CENTER",0,0) | |
but.tex:SetWidth(75) | |
but.tex:SetHeight(20) | |
--but.tex:SetAllPoints(but) | |
but:SetScript("OnMouseDown", function() | |
local CcallBack = function(restore) | |
local newR, newG, newB | |
if restore then | |
-- The user bailed, we extract the old color from the table created by ShowColorPicker. | |
newR, newG, newB = unpack(restore) | |
else | |
-- Something changed | |
newR, newG, newB = ColorPickerFrame:GetColorRGB() | |
end | |
E_Saved.colors[sliders[i].name].r=newR | |
E_Saved.colors[sliders[i].name].g=newG | |
E_Saved.colors[sliders[i].name].b=newB | |
colorButtons[i].func() | |
E:eclipse() | |
but.tex:SetTexture(newR,newG,newB) | |
end | |
ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = CcallBack, CcallBack, CcallBack | |
ColorPickerFrame:SetColorRGB(colorButtons[i].value.r,colorButtons[i].value.g,colorButtons[i].value.b) | |
ColorPickerFrame.previousValues = {colorButtons[i].value.r,colorButtons[i].value.g,colorButtons[i].value.b} | |
ColorPickerFrame:Hide() -- Need to run the OnShow handler. | |
ColorPickerFrame:Show() | |
ColorPickerFrame:SetFrameStrata("TOOLTIP") | |
end) | |
end | |
end | |
------------------------- | |
-- TAB Control Buttons -- | |
------------------------- | |
local butGeneral = CreateFrame("Button", "butGeneral", optionsframe, "UIPanelButtonTemplate") | |
butGeneral:SetText("General") | |
butGeneral:SetHeight(24) | |
butGeneral:SetWidth(75) | |
butGeneral:SetPoint("CENTER",optionsframe,"TOPLEFT",60,-50) | |
butGeneral:SetScript("OnClick",function() | |
myTabPage1:Show() | |
myTabPage2:Hide() | |
end) | |
local butAppearance = CreateFrame("Button", "butAppearance", optionsframe, "UIPanelButtonTemplate") | |
butAppearance:SetText("Appearance") | |
butAppearance:SetHeight(24) | |
butAppearance:SetWidth(100) | |
butAppearance:SetPoint("CENTER",optionsframe,"TOPLEFT",150,-50) | |
butAppearance:SetScript("OnClick",function() | |
myTabPage2:Show() | |
myTabPage1:Hide() | |
end) | |
optionsframe:SetScript("OnDragStart", function(self) self:StartMoving() end) | |
optionsframe:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) | |
optionsframe:SetScript("OnShow", function(self) | |
myTabPage1:Show() | |
myTabPage2:Hide() | |
end) | |
optionsframe:SetFrameStrata("FULLSCREEN") | |
tinsert(UISpecialFrames, "E_OptionsFrame") | |
local header = optionsframe:CreateTexture(nil,"ARTWORK") | |
header:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header.blp") | |
header:SetWidth(350) | |
header:SetHeight(68) | |
header:SetPoint("TOP",optionsframe,"TOP",0,12) | |
local headertext = optionsframe:CreateFontString(nil,"ARTWORK","GameFontNormal") | |
headertext:SetPoint("TOP",header,"TOP",0,-14) | |
headertext:SetText("Eclipsor") | |
for i,v in pairs(buttons) do | |
local button = CreateFrame("Button", "E_OptionsFrameButton"..i, optionsframe, "UIPanelButtonTemplate") | |
button:SetHeight(24) | |
button:SetWidth(75) | |
button:SetPoint("BOTTOM", optionsframe, "BOTTOM", ((i%2==0 and -1) or 1)*45, ceil(i/2)*15 + (ceil(i/2)-1)*15) | |
button:SetText(v.text) | |
button:SetScript("OnClick", function(self) PlaySound("igMainMenuOption") v.func(self) end) | |
end | |
end |
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
## Interface: 90005 | |
## Title: Eclipsor | |
## Notes: Eclipsor | |
## OptionalDeps: | |
## Dependencies: | |
## SavedVariables: E_Saved | |
Eclipsor.lua |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment