This commit is contained in:
Crum
2018-11-01 22:32:19 -05:00
parent 355c8fcac2
commit 7d7fdb61ab
49 changed files with 1617 additions and 193 deletions
+49 -4
View File
@@ -38,12 +38,24 @@ function FarmMode()
if Minimap:IsShown() then
UIFrameFadeOut(Minimap, 0.3)
UIFrameFadeIn(FarmModeMap, 0.3)
Minimap.fadeInfo.finishedFunc = function() Minimap:Hide() Minimap.backdrop:Hide() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end
Minimap.fadeInfo.finishedFunc = function()
Minimap:Hide()
Minimap.backdrop:Hide()
_G.MinimapZoomIn:Click()
_G.MinimapZoomOut:Click()
Minimap:SetAlpha(1)
end
FarmModeMap.enabled = true
else
UIFrameFadeOut(FarmModeMap, 0.3)
UIFrameFadeIn(Minimap, 0.3)
FarmModeMap.fadeInfo.finishedFunc = function() FarmModeMap:Hide() Minimap.backdrop:Show() _G.MinimapZoomIn:Click() _G.MinimapZoomOut:Click() Minimap:SetAlpha(1) end
FarmModeMap.fadeInfo.finishedFunc = function()
FarmModeMap:Hide()
Minimap.backdrop:Show()
_G.MinimapZoomIn:Click()
_G.MinimapZoomOut:Click()
Minimap:SetAlpha(1)
end
FarmModeMap.enabled = false
end
end
@@ -75,6 +87,8 @@ function E:LuaError(msg)
msg = lower(msg)
if msg == "on" then
DisableAllAddOns()
EnableAddOn("!Compatibility")
EnableAddOn("!DebugTools")
EnableAddOn("ElvUI")
EnableAddOn("ElvUI_Config")
SetCVar("ShowErrors", "1")
@@ -114,7 +128,36 @@ function E:DelayScriptCall(msg)
self:Print("usage: /in <seconds> <command>")
self:Print("example: /in 1.5 /say hi")
else
E:ScheduleTimer(OnCallback, secs, command)
E:Delay(secs, OnCallback, command)
end
end
local BLIZZARD_ADDONS = {
"Blizzard_AuctionUI",
"Blizzard_BattlefieldMinimap",
"Blizzard_BindingUI",
"Blizzard_CombatLog",
"Blizzard_CombatText",
"Blizzard_CraftUI",
"Blizzard_GMSurveyUI",
"Blizzard_GuildBankUI",
"Blizzard_InspectUI",
"Blizzard_ItemSocketingUI",
"Blizzard_MacroUI",
"Blizzard_RaidUI",
"Blizzard_TalentUI",
"Blizzard_TimeManager",
"Blizzard_TradeSkillUI",
"Blizzard_TrainerUI"
}
function E:EnableBlizzardAddOns()
for _, addon in pairs(BLIZZARD_ADDONS) do
local reason = select(5, GetAddOnInfo(addon))
if reason == "DISABLED" then
EnableAddOn(addon)
E:Print("The following addon was re-enabled:", addon)
end
end
end
@@ -130,8 +173,10 @@ function E:LoadCommands()
self:RegisterChatCommand("enable", "EnableAddon")
self:RegisterChatCommand("disable", "DisableAddon")
self:RegisterChatCommand("farmmode", "FarmMode")
self:RegisterChatCommand("enableblizzard", "EnableBlizzardAddOns")
self:RegisterChatCommand("estatus", "ShowStatusReport")
if E:GetModule("ActionBars") and E.private.actionbar.enable then
self:RegisterChatCommand("kb", E:GetModule("ActionBars").ActivateBindMode)
end
end
end
+3 -1
View File
@@ -15,4 +15,6 @@
<Script file="Cooldowns.lua"/>
<Script file="pluginInstaller.lua"/>
<Script file="ClassCache.lua"/>
</Ui>
<Script file="StatusReport.lua"/>
<Script file="modulecopy.lua"/>
</Ui>
+235
View File
@@ -0,0 +1,235 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Cache global variables
--Lua functions
local select = select
local max = math.max
--WoW API / Variables
local CreateFrame = CreateFrame
local GetAddOnInfo = GetAddOnInfo
local GetCurrentResolution = GetCurrentResolution
local GetCVar = GetCVar
local GetLocale = GetLocale
local GetNumAddOns = GetNumAddOns
local GetRealZoneText = GetRealZoneText
local GetScreenResolutions = GetScreenResolutions
local UnitLevel = UnitLevel
local function AreOtherAddOnsEnabled()
local name, loadable, reason, _
for i = 1, GetNumAddOns() do
name, _, _, loadable, reason = GetAddOnInfo(i)
if (name ~= "ElvUI" and name ~= "ElvUI_Config" and name ~= "!Compatibility" and name ~= "!DebugTools") and (loadable or (not loadable and reason == "DEMAND_LOADED")) then --Loaded or load on demand
return "Yes"
end
end
return "No"
end
local function GetUiScale()
local uiScale = GetCVar("uiScale")
local minUiScale = E.global.general.minUiScale
return max(uiScale, minUiScale)
end
local function GetDisplayMode()
local window, maximize = GetCVar("gxWindow"), GetCVar("gxMaximize")
local displayMode
if window == "1" then
if maximize == "1" then
displayMode = "Windowed (Fullscreen)"
else
displayMode = "Windowed"
end
else
displayMode = "Fullscreen"
end
return displayMode
end
local EnglishClassName = {
["DRUID"] = "Druid",
["HUNTER"] = "Hunter",
["MAGE"] = "Mage",
["PALADIN"] = "Paladin",
["PRIEST"] = "Priest",
["ROGUE"] = "Rogue",
["SHAMAN"] = "Shaman",
["WARLOCK"] = "Warlock",
["WARRIOR"] = "Warrior"
}
local function GetResolution()
return (({GetScreenResolutions()})[GetCurrentResolution()] or GetCVar("gxWindowedResolution"))
end
function E:CreateStatusFrame()
local function CreateSection(width, height, parent, anchor1, anchorTo, anchor2, yOffset)
local section = CreateFrame("Frame", nil, parent)
E:Size(section, width, height)
E:Point(section, anchor1, anchorTo, anchor2, 0, yOffset)
section.Header = CreateFrame("Frame", nil, section)
E:Size(section.Header, 300, 30)
E:Point(section.Header, "TOP", section)
section.Header.Text = section.Header:CreateFontString(nil, "ARTWORK", "SystemFont")
E:Point(section.Header.Text, "TOP")
E:Point(section.Header.Text, "BOTTOM")
section.Header.Text:SetJustifyH("CENTER")
section.Header.Text:SetJustifyV("MIDDLE")
local font, height, flags = section.Header.Text:GetFont()
section.Header.Text:SetFont(font, height*1.3, flags)
section.Header.LeftDivider = section.Header:CreateTexture(nil, "ARTWORK")
E:Height(section.Header.LeftDivider, 8)
E:Point(section.Header.LeftDivider, "LEFT", section.Header, "LEFT", 5, 0)
E:Point(section.Header.LeftDivider, "RIGHT", section.Header.Text, "LEFT", -5, 0)
section.Header.LeftDivider:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
section.Header.LeftDivider:SetTexCoord(0.81, 0.94, 0.5, 1)
section.Header.RightDivider = section.Header:CreateTexture(nil, "ARTWORK")
E:Height(section.Header.RightDivider, 8)
E:Point(section.Header.RightDivider, "RIGHT", section.Header, "RIGHT", -5, 0)
E:Point(section.Header.RightDivider, "LEFT", section.Header.Text, "RIGHT", 5, 0)
section.Header.RightDivider:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
section.Header.RightDivider:SetTexCoord(0.81, 0.94, 0.5, 1)
return section
end
local function CreateContentLines(num, parent, anchorTo)
local content = CreateFrame("Frame", nil, parent)
E:Size(content, 240, (num * 20) + ((num - 1) * 5)) --20 height and 5 spacing
E:Point(content, "TOP", anchorTo, "BOTTOM", 0, -5)
for i = 1, num do
local line = CreateFrame("Frame", nil, content)
E:Size(line, 240, 20)
line.Text = line:CreateFontString(nil, "ARTWORK", "SystemFont")
line.Text:SetTextColor(1, 1, 1)
line.Text:SetAllPoints()
line.Text:SetJustifyH("LEFT")
line.Text:SetJustifyV("MIDDLE")
content["Line"..i] = line
if i == 1 then
E:Point(content["Line"..i], "TOP", content, "TOP")
else
E:Point(content["Line"..i], "TOP", content["Line"..(i - 1)], "BOTTOM", 0, -5)
end
end
return content
end
--Main frame
local StatusFrame = CreateFrame("Frame", "ElvUIStatusReport", E.UIParent)
E:Size(StatusFrame, 300, 640)
E:Point(StatusFrame, "CENTER", E.UIParent, "CENTER")
StatusFrame:SetFrameStrata("HIGH")
E:CreateBackdrop(StatusFrame, "Transparent", nil, true)
StatusFrame:Hide()
E:CreateCloseButton(StatusFrame)
StatusFrame:SetClampedToScreen(true)
StatusFrame:SetMovable(true)
StatusFrame:EnableMouse(true)
StatusFrame:RegisterForDrag("LeftButton", "RightButton")
StatusFrame:SetScript("OnDragStart", function()
this:StartMoving()
end)
StatusFrame:SetScript("OnDragStop", function()
this:StopMovingOrSizing()
end)
--Title logo
StatusFrame.TitleLogoFrame = CreateFrame("Frame", nil, StatusFrame)
E:Size(StatusFrame.TitleLogoFrame, 128, 64)
E:Point(StatusFrame.TitleLogoFrame, "CENTER", StatusFrame, "TOP", 0, 0)
StatusFrame.TitleLogoFrame.Texture = StatusFrame.TitleLogoFrame:CreateTexture(nil, "ARTWORK")
StatusFrame.TitleLogoFrame.Texture:SetTexture("Interface\\AddOns\\ElvUI\\media\\textures\\logo.tga")
StatusFrame.TitleLogoFrame.Texture:SetAllPoints()
--Sections
StatusFrame.Section1 = CreateSection(300, 150, StatusFrame, "TOP", StatusFrame, "TOP", -30)
StatusFrame.Section2 = CreateSection(300, 175, StatusFrame, "TOP", StatusFrame.Section1, "BOTTOM", 0)
StatusFrame.Section3 = CreateSection(300, 220, StatusFrame, "TOP", StatusFrame.Section2, "BOTTOM", 0)
StatusFrame.Section4 = CreateSection(300, 60, StatusFrame, "TOP", StatusFrame.Section3, "BOTTOM", 0)
--Section headers
StatusFrame.Section1.Header.Text:SetText("|cfffe7b2cAddOn Info|r")
StatusFrame.Section2.Header.Text:SetText("|cfffe7b2cWoW Info|r")
StatusFrame.Section3.Header.Text:SetText("|cfffe7b2cCharacter Info|r")
StatusFrame.Section4.Header.Text:SetText("|cfffe7b2cExport To|r")
--Section content
StatusFrame.Section1.Content = CreateContentLines(4, StatusFrame.Section1, StatusFrame.Section1.Header)
StatusFrame.Section2.Content = CreateContentLines(5, StatusFrame.Section2, StatusFrame.Section2.Header)
StatusFrame.Section3.Content = CreateContentLines(7, StatusFrame.Section3, StatusFrame.Section3.Header)
StatusFrame.Section4.Content = CreateFrame("Frame", nil, StatusFrame.Section4)
E:Size(StatusFrame.Section4.Content, 240, 25)
E:Point(StatusFrame.Section4.Content, "TOP", StatusFrame.Section4.Header, "BOTTOM", 0, 0)
--Content lines
StatusFrame.Section1.Content.Line1.Text:SetText(format("Version of ElvUI: |cff4beb2c%s|r", E.version))
StatusFrame.Section1.Content.Line2.Text:SetText(format("Other AddOns Enabled: |cff4beb2c%s|r", AreOtherAddOnsEnabled()))
StatusFrame.Section1.Content.Line3.Text:SetText(format("Auto Scale Enabled: |cff4beb2c%s|r", (E.global.general.autoScale == true and "Yes" or "No")))
StatusFrame.Section1.Content.Line4.Text:SetText(format("UI Scale Is: |cff4beb2c%.4f|r", GetUiScale()))
StatusFrame.Section2.Content.Line1.Text:SetText(format("Version of WoW: |cff4beb2c%s (build %s)|r", E.wowpatch, E.wowbuild))
StatusFrame.Section2.Content.Line2.Text:SetText(format("Client Language: |cff4beb2c%s|r", GetLocale()))
StatusFrame.Section2.Content.Line3.Text:SetText(format("Display Mode: |cff4beb2c%s|r", GetDisplayMode()))
StatusFrame.Section2.Content.Line4.Text:SetText(format("Resolution: |cff4beb2c%s|r", GetResolution()))
StatusFrame.Section2.Content.Line5.Text:SetText(format("Using Mac Client: |cff4beb2c%s|r", (E.isMacClient == true and "Yes" or "No")))
StatusFrame.Section3.Content.Line1.Text:SetText(format("Faction: |cff4beb2c%s|r", E.myfaction))
StatusFrame.Section3.Content.Line2.Text:SetText(format("Race: |cff4beb2c%s|r", E.myrace))
StatusFrame.Section3.Content.Line3.Text:SetText(format("Class: |cff4beb2c%s|r", EnglishClassName[E.myclass]))
StatusFrame.Section3.Content.Line4.Text:SetText(format("Specialization: |cff4beb2c%s|r", select(2, E:GetTalentSpecInfo())))
StatusFrame.Section3.Content.Line5.Text:SetText(format("Level: |cff4beb2c%s|r", UnitLevel("player")))
StatusFrame.Section3.Content.Line6.Text:SetText(format("Zone: |cff4beb2c%s|r", GetRealZoneText()))
StatusFrame.Section3.Content.Line7.Text:SetText(format("Realm: |cff4beb2c%s|r", E.myrealm))
--Export buttons
StatusFrame.Section4.Content.Button1 = CreateFrame("Button", nil, StatusFrame.Section4.Content, "UIPanelButtonTemplate")
E:Size(StatusFrame.Section4.Content.Button1, 100, 25)
E:Point(StatusFrame.Section4.Content.Button1, "LEFT", StatusFrame.Section4.Content, "LEFT")
StatusFrame.Section4.Content.Button1:SetText("Forum")
StatusFrame.Section4.Content.Button1:SetButtonState("DISABLED")
E:GetModule("Skins"):HandleButton(StatusFrame.Section4.Content.Button1, true)
StatusFrame.Section4.Content.Button2 = CreateFrame("Button", nil, StatusFrame.Section4.Content, "UIPanelButtonTemplate")
E:Size(StatusFrame.Section4.Content.Button2, 100, 25)
E:Point(StatusFrame.Section4.Content.Button2, "RIGHT", StatusFrame.Section4.Content, "RIGHT")
StatusFrame.Section4.Content.Button2:SetText("Ticket")
StatusFrame.Section4.Content.Button2:SetButtonState("DISABLED")
E:GetModule("Skins"):HandleButton(StatusFrame.Section4.Content.Button2, true)
E.StatusFrame = StatusFrame
end
local function UpdateDynamicValues()
E.StatusFrame.Section2.Content.Line3.Text:SetText(format("Display Mode: |cff4beb2c%s|r", GetDisplayMode()))
E.StatusFrame.Section2.Content.Line4.Text:SetText(format("Resolution: |cff4beb2c%s|r", GetResolution()))
E.StatusFrame.Section3.Content.Line4.Text:SetText(format("Specialization: |cff4beb2c%s|r", select(2, E:GetTalentSpecInfo())))
E.StatusFrame.Section3.Content.Line5.Text:SetText(format("Level: |cff4beb2c%s|r", UnitLevel("player")))
E.StatusFrame.Section3.Content.Line6.Text:SetText(format("Zone: |cff4beb2c%s|r", GetRealZoneText()))
end
function E:ShowStatusReport()
if not self.StatusFrame then
self:CreateStatusFrame()
end
if not self.StatusFrame:IsShown() then
UpdateDynamicValues()
self.StatusFrame:Raise() --Set framelevel above everything else
self.StatusFrame:Show()
else
self.StatusFrame:Hide()
end
end
+178 -144
View File
@@ -18,24 +18,24 @@ local IsAddOnLoaded = IsAddOnLoaded
local IsInInstance, GetNumPartyMembers, GetNumRaidMembers = IsInInstance, GetNumPartyMembers, GetNumRaidMembers
local RequestBattlefieldScoreData = RequestBattlefieldScoreData
local SendAddonMessage = SendAddonMessage
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
local NONE = NONE
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local _
_, E.myclass = UnitClass("player") -- Constants
_, E.myrace = UnitRace("player")
_, E.myfaction = UnitFactionGroup("player")
-- The E.myfaction may error when in GM mode
E.myfaction = E.myfaction or "Others"
E.myname = UnitName("player")
E.version = GetAddOnMetadata("ElvUI", "Version")
E.myrealm = GetRealmName()
_, E.wowbuild = GetBuildInfo() E.wowbuild = tonumber(E.wowbuild)
E.resolution = GetCVar("gxResolution")
E.screenheight = tonumber(match(E.resolution, "%d+x(%d+)"));
E.screenwidth = tonumber(match(E.resolution, "(%d+)x+%d"));
E.isMacClient = IsMacClient()
-- Constants
E.LSM = LSM
E.noop = function() end
E.title = format("|cff175581E|r|cffC4C4C4lvUI|r")
E.myfaction, E.myLocalizedFaction = UnitFactionGroup("player")
E.myLocalizedClass, E.myclass, E.myClassID = UnitClass("player")
E.myLocalizedRace, E.myrace = UnitRace("player")
E.myname = UnitName("player")
E.myrealm = GetRealmName()
E.version = GetAddOnMetadata("ElvUI", "Version")
E.wowpatch, E.wowbuild = GetBuildInfo() E.wowbuild = tonumber(E.wowbuild)
E.resolution = GetCVar("gxResolution")
E.screenheight = tonumber(match(E.resolution, "%d+x(%d+)"))
E.screenwidth = tonumber(match(E.resolution, "(%d+)x+%d"))
E.isMacClient = IsMacClient()
E["media"] = {}
E["frames"] = {}
@@ -85,14 +85,7 @@ E.DispelClasses = {
["DRUID"] = {
["Curse"] = true,
["Poison"] = true
},
}
E.HealingClasses = {
PALADIN = 1,
SHAMAN = 3,
DRUID = 3,
PRIEST = {1, 2}
}
}
E.ClassRole = {
@@ -123,19 +116,13 @@ E.ClassRole = {
}
}
E.DEFAULT_FILTER = {
["CCDebuffs"] = "Whitelist",
["TurtleBuffs"] = "Whitelist",
["PlayerBuffs"] = "Whitelist",
["Blacklist"] = "Blacklist",
["Whitelist"] = "Whitelist",
["RaidDebuffs"] = "Whitelist",
}
E.noop = function() end
E.DEFAULT_FILTER = {}
for filter, tbl in pairs(G.unitframe.aurafilters) do
E.DEFAULT_FILTER[filter] = tbl.type
end
local colorizedName
function E:ColorizedName(name, colon)
function E:ColorizedName(name, arg2)
local length = len(name)
for i = 1, length do
local letter = sub(name, i, i)
@@ -143,7 +130,7 @@ function E:ColorizedName(name, colon)
colorizedName = format("|cff175581%s", letter)
elseif i == 2 then
colorizedName = format("%s|r|cffC4C4C4%s", colorizedName, letter)
elseif i == length and colon then
elseif i == length and arg2 then
colorizedName = format("%s%s|r|cff175581:|r", colorizedName, letter)
else
colorizedName = colorizedName..letter
@@ -153,7 +140,7 @@ function E:ColorizedName(name, colon)
end
function E:Print(msg)
print(self:ColorizedName("ElvUI", true), msg)
print(_G[self.db.general.messageRedirect] or DEFAULT_CHAT_FRAME):AddMessage(strjoin("", self:ColorizedName("ElvUI", true), msg)) -- I put DEFAULT_CHAT_FRAME as a fail safe.
end
E.PriestColors = {
@@ -162,19 +149,21 @@ E.PriestColors = {
b = 0.99
}
function E:GetPlayerRole()
local assignedRole = UnitGroupRolesAssigned("player")
if assignedRole == "NONE" or not assignedRole then
if self.HealingClasses[self.myclass] ~= nil and self:CheckTalentTree(self.HealingClasses[E.myclass]) then
return "HEALER"
elseif E.Role == "Tank" then
return "TANK"
else
return "DAMAGER"
local delayedTimer
local delayedFuncs = {}
function E:ShapeshiftDelayedUpdate(func, ...)
delayedFuncs[func] = {unpack(arg)}
if delayedTimer then return end
delayedTimer = E:ScheduleTimer(function()
for func in pairs(delayedFuncs) do
func(unpack(delayedFuncs[func]))
end
else
return assignedRole
end
twipe(delayedFuncs)
delayedTimer = nil
end, 0.05)
end
function E:CheckClassColor(r, g, b)
@@ -205,7 +194,7 @@ function E:GetColorTable(data)
end
function E:UpdateMedia()
if (not self.db["general"] or not self.private["general"]) then return end
if not (self.db and self.db["general"] and self.private["general"]) then return end
-- Fonts
self["media"].normFont = LSM:Fetch("font", self.db["general"].font)
@@ -271,7 +260,7 @@ end
local function LSMCallback()
E:UpdateMedia()
end
E.LSM.RegisterCallback(E, "LibSharedMedia_Registered", LSMCallback)
LSM.RegisterCallback(E, "LibSharedMedia_Registered", LSMCallback)
local LBF = LibStub("LibButtonFacade", true)
@@ -282,6 +271,7 @@ local LBFGroupToTableElement = {
function E:LBFCallback(SkinID, _, _, Group)
if not E.private then return end
local element = LBFGroupToTableElement[Group]
if element then
if E.private[element].lbf.enable then
@@ -299,11 +289,11 @@ function E:RequestBGInfo()
end
function E:PLAYER_ENTERING_WORLD()
-- self:ScheduleTimer("CheckRole", 0.01)
if not self.MediaUpdated then
self:UpdateMedia()
self.MediaUpdated = true
-- else
-- self:ScheduleTimer("CheckRole", 0.01)
end
local _, instanceType = IsInInstance()
@@ -426,7 +416,7 @@ E.UIParent:SetFrameLevel(UIParent:GetFrameLevel())
E.UIParent:SetPoint("CENTER", UIParent, "CENTER")
E.UIParent:SetHeight(GetScreenHeight())
E.UIParent:SetWidth(GetScreenWidth())
tinsert(E["snapBars"], E.UIParent)
E["snapBars"][getn(E["snapBars"]) + 1] = E.UIParent
E.HiddenFrame = CreateFrame("Frame")
E.HiddenFrame:Hide()
@@ -439,11 +429,11 @@ function E:IsDispellableByMe(debuffType)
end
end
function E:GetTalentSpecInfo()
function E:GetTalentSpecInfo(isInspect)
local maxPoints, specIdx, specName, specIcon = 0, 0
for i = 1, 3 do
local name, icon, pointsSpent = GetTalentTabInfo(i)
local name, icon, pointsSpent = GetTalentTabInfo(i, isInspect)
if maxPoints < pointsSpent then
maxPoints = pointsSpent
specIdx = i
@@ -453,7 +443,7 @@ function E:GetTalentSpecInfo()
end
if not specName then
specName = "None"
specName = NONE
end
if not specIcon then
specIcon = "Interface\\Icons\\INV_Misc_QuestionMark"
@@ -462,19 +452,6 @@ function E:GetTalentSpecInfo()
return specIdx, specName, specIcon
end
function E:CheckTalentTree(tree)
local talentTree = self.TalentTree
if not talentTree then return false end
if type(tree) == "number" then
return tree == talentTree
elseif type(tree) == "table" then
for _, index in pairs(tree) do
return index == talentTree
end
end
end
function E:CheckRole()
local talentTree = self:GetTalentSpecInfo()
local role
@@ -602,6 +579,38 @@ function E:RemoveTableDuplicates(cleanTable, checkTable)
return cleaned
end
--Compare 2 tables and remove blacklisted key/value pairs
--param cleanTable : table you want cleaned
--param blacklistTable : table you want to check against.
--return : a copy of cleanTable with blacklisted key/value pairs removed
function E:FilterTableFromBlacklist(cleanTable, blacklistTable)
if type(cleanTable) ~= "table" then
E:Print("Bad argument #1 to 'FilterTableFromBlacklist' (table expected)")
return
end
if type(blacklistTable) ~= "table" then
E:Print("Bad argument #2 to 'FilterTableFromBlacklist' (table expected)")
return
end
local cleaned = {}
for option, value in pairs(cleanTable) do
if type(value) == "table" and blacklistTable[option] and type(blacklistTable[option]) == "table" then
cleaned[option] = self:FilterTableFromBlacklist(value, blacklistTable[option])
else
-- Filter out blacklisted keys
if blacklistTable[option] ~= true then
cleaned[option] = value
end
end
end
--Clean out empty sub-tables
self:RemoveEmptySubTables(cleaned)
return cleaned
end
function E:TableToLuaString(inTable)
if type(inTable) ~= "table" then
E:Print("Invalid argument #1 to E:TableToLuaString (table expected)")
@@ -611,30 +620,30 @@ function E:TableToLuaString(inTable)
local ret = "{\n"
local function recurse(table, level)
for i, v in pairs(table) do
ret = ret .. strrep(" ", level).."["
ret = ret..strrep(" ", level).."["
if type(i) == "string" then
ret = ret .. "\"" .. i .. "\""
ret = ret.."\""..i.."\""
else
ret = ret .. i
ret = ret..i
end
ret = ret .. "] = "
ret = ret.."] = "
if type(v) == "number" then
ret = ret .. v .. ",\n"
ret = ret..v..",\n"
elseif type(v) == "string" then
ret = ret .. "\"" .. gsub(gsub(gsub(v, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"") .. "\",\n"
ret = ret.."\""..gsub(gsub(gsub(v, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"").."\",\n"
elseif type(v) == "boolean" then
if v then
ret = ret .. "true,\n"
ret = ret.."true,\n"
else
ret = ret .. "false,\n"
ret = ret.."false,\n"
end
elseif type(v) == "table" then
ret = ret .. "{\n"
ret = ret.."{\n"
recurse(v, level + 1)
ret = ret .. strrep(" ", level) .. "},\n"
ret = ret..strrep(" ", level).."},\n"
else
ret = ret .. "\""..tostring(v) .. "\",\n"
ret = ret.."\""..tostring(v).."\",\n"
end
end
end
@@ -651,18 +660,15 @@ local profileFormat = {
["profile"] = "E.db",
["private"] = "E.private",
["global"] = "E.global",
["filtersNP"] = "E.global",
["filtersUF"] = "E.global",
["filtersAll"] = "E.global"
["filters"] = "E.global",
["styleFilters"] = "E.global"
}
local lineStructureTable = {}
function E:ProfileTableToPluginFormat(inTable, profileType)
local profileText = profileFormat[profileType]
if not profileText then
return
end
if not profileText then return end
twipe(lineStructureTable)
local returnString = ""
@@ -673,9 +679,9 @@ function E:ProfileTableToPluginFormat(inTable, profileType)
local str = profileText
for _, v in ipairs(lineStructureTable) do
if type(v) == "string" then
str = str .. "[\"" .. v .. "\"]"
str = str.."[\""..v.."\"]"
else
str = str .. "[" .. v .. "]"
str = str.."["..v.."]"
end
end
@@ -686,38 +692,38 @@ function E:ProfileTableToPluginFormat(inTable, profileType)
lineStructure = buildLineStructure()
for k, v in pairs(tbl) do
if not sameLine then
returnString = returnString .. lineStructure
returnString = returnString..lineStructure
end
returnString = returnString .. "["
returnString = returnString.."["
if type(k) == "string" then
returnString = returnString.."\"" .. k .. "\""
returnString = returnString.."\""..k.."\""
else
returnString = returnString .. k
returnString = returnString..k
end
if type(v) == "table" then
tinsert(lineStructureTable, k)
sameLine = true
returnString = returnString .. "]"
returnString = returnString.."]"
recurse(v)
else
sameLine = false
returnString = returnString .. "] = "
returnString = returnString.."] = "
if type(v) == "number" then
returnString = returnString .. v .. "\n"
returnString = returnString..v.."\n"
elseif type(v) == "string" then
returnString = returnString .. "\"" .. gsub(gsub(gsub(v, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"") .. "\"\n"
returnString = returnString.."\""..gsub(gsub(gsub(v, "\\", "\\\\"), "\n", "\\n"), "\"", "\\\"").."\"\n"
elseif type(v) == "boolean" then
if v then
returnString = returnString .. "true\n"
returnString = returnString.."true\n"
else
returnString = returnString .. "false\n"
returnString = returnString.."false\n"
end
else
returnString = returnString .. "\"" .. tostring(v) .. "\"\n"
returnString = returnString.."\""..tostring(v).."\"\n"
end
end
end
@@ -739,7 +745,7 @@ function E:StringSplitMultiDelim(s, delim)
local start = 1
local t = {}
while true do
while(true) do
local pos = find(s, delim, start, true)
if not pos then
break
@@ -754,53 +760,61 @@ function E:StringSplitMultiDelim(s, delim)
return unpack(t)
end
local SendMessageTimer -- prevent setting multiple timers at once
function E:SendMessage()
local numParty, numRaid = GetNumPartyMembers(), GetNumRaidMembers()
local inInstance, instanceType = IsInInstance()
if inInstance and (instanceType == "pvp") then
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "BATTLEGROUND")
else
if numRaid > 0 then
local numRaid, numParty = GetNumRaidMembers(), GetNumPartyMembers()
if numRaid > 1 then
local _, instanceType = IsInInstance()
if instanceType == "pvp" then
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "BATTLEGROUND")
else
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "RAID")
elseif numParty > 0 then
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "PARTY")
end
elseif numParty > 0 then
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "PARTY")
elseif IsInGuild() then
SendAddonMessage("ELVUI_VERSIONCHK", E.version, "GUILD")
end
if E.SendMSGTimer then
self:CancelTimer(E.SendMSGTimer)
E.SendMSGTimer = nil
end
SendMessageTimer = nil
end
local SendRecieveGroupSize
local SendRecieveGroupSize = 0
local function SendRecieve()
if not E.global.general.versionCheck then return end
if event == "CHAT_MSG_ADDON" then
if arg1 ~= "ELVUI_VERSIONCHK" then return end
if not arg4 or arg4 == E.myname or E.recievedOutOfDateMessage then return end
if sender == E.myname then return end
arg2 = tonumber(arg2)
if prefix == "ELVUI_VERSIONCHK" then
local msg, ver = tonumber(message), tonumber(E.version)
if msg and (msg > ver) then -- you're outdated D:
if not E.recievedOutOfDateMessage then
E:Print(L["ElvUI is out of date. You can download the newest version from https://github.com/ElvUI-TBC/ElvUI/"])
if arg2 and arg2 > tonumber(E.version) then
E:Print(L["ElvUI is out of date. You can download the newest version from https://github.com/ElvUI-Vanilla/ElvUI/"])
if msg and ((msg - ver) >= 0.01) then
E:StaticPopup_Show("ELVUI_UPDATE_AVAILABLE")
end
if arg2 - tonumber(E.version) >= 0.05 then
E:StaticPopup_Show("ELVUI_UPDATE_AVAILABLE")
E.recievedOutOfDateMessage = true
end
elseif msg and (msg < ver) then -- Send Message Back if you intercept and are higher revision
if not SendMessageTimer then
SendMessageTimer = E:ScheduleTimer("SendMessage", 10)
end
end
E.recievedOutOfDateMessage = true
end
else
elseif event == "PARTY_MEMBERS_CHANGED" or event == "RAID_ROSTER_UPDATE" then
local numRaid, numParty = GetNumRaidMembers(), GetNumPartyMembers() + 1
local num = numRaid > 0 and numRaid or numParty
if num ~= SendRecieveGroupSize then
if num > 1 and SendRecieveGroupSize and num > SendRecieveGroupSize then
E.SendMSGTimer = E:ScheduleTimer("SendMessage", 12)
if num > 1 and num > SendRecieveGroupSize then
if not SendMessageTimer then
SendMessageTimer = E:ScheduleTimer("SendMessage", 10)
end
end
SendRecieveGroupSize = num
end
elseif not SendMessageTimer then
SendMessageTimer = E:ScheduleTimer("SendMessage", 10)
end
end
@@ -808,6 +822,7 @@ local f = CreateFrame("Frame")
f:RegisterEvent("RAID_ROSTER_UPDATE")
f:RegisterEvent("PARTY_MEMBERS_CHANGED")
f:RegisterEvent("CHAT_MSG_ADDON")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", SendRecieve)
function E:UpdateAll(ignoreInstall)
@@ -819,7 +834,7 @@ function E:UpdateAll(ignoreInstall)
self:SetMoversPositions()
self:UpdateMedia()
self:UpdateCooldownSettings()
self:UpdateCooldownSettings("all")
local UF = self:GetModule("UnitFrames")
UF.db = self.db.unitframe
@@ -835,6 +850,7 @@ function E:UpdateAll(ignoreInstall)
AB.db = self.db.actionbar
AB:UpdateButtonSettings()
AB:UpdateMicroPositionDimensions()
AB:ToggleDesaturation()
local bags = E:GetModule("Bags")
bags.db = self.db.bags
@@ -844,6 +860,11 @@ function E:UpdateAll(ignoreInstall)
bags:UpdateItemLevelDisplay()
bags:UpdateCountDisplay()
local totems = E:GetModule("Totems")
totems.db = self.db.general.totems
totems:PositionAndSize()
totems:ToggleEnable()
self:GetModule("Layout"):ToggleChatPanels()
local DT = self:GetModule("DataTexts")
@@ -852,6 +873,7 @@ function E:UpdateAll(ignoreInstall)
local NP = self:GetModule("NamePlates")
NP.db = self.db.nameplates
NP:StyleFilterInitializeAllFilters()
NP:ConfigureAll()
local DataBars = self:GetModule("DataBars")
@@ -860,16 +882,21 @@ function E:UpdateAll(ignoreInstall)
DataBars:EnableDisable_ExperienceBar()
DataBars:EnableDisable_ReputationBar()
local T = self:GetModule("Threat")
T.db = self.db.general.threat
T:UpdatePosition()
T:ToggleEnable()
self:GetModule("Auras").db = self.db.auras
self:GetModule("Tooltip").db = self.db.tooltip
if ElvUIPlayerBuffs then
E:GetModule("Auras"):UpdateHeader(ElvUIPlayerBuffs)
end
-- if ElvUIPlayerBuffs then
-- E:GetModule("Auras"):UpdateHeader(ElvUIPlayerBuffs)
-- end
if ElvUIPlayerDebuffs then
E:GetModule("Auras"):UpdateHeader(ElvUIPlayerDebuffs)
end
-- if ElvUIPlayerDebuffs then
-- E:GetModule("Auras"):UpdateHeader(ElvUIPlayerDebuffs)
-- end
if not (self.private.install_complete or ignoreInstall) then
self:Install()
@@ -890,7 +917,7 @@ function E:UpdateAll(ignoreInstall)
LO:TopPanelVisibility()
LO:SetDataPanelStyle()
self:GetModule("Blizzard"):SetWatchFrameHeight()
collectgarbage("collect")
end
function E:ResetAllUI()
@@ -1056,6 +1083,9 @@ function E:GetTopCPUFunc(msg)
E:Print("cpuusage: module (arg1) is required! This can be set as 'all' too.")
return
end
local module, showall, delay, minCalls = msg:match("^(%S+)%s*(%S*)%s*(%S*)%s*(.*)$")
local checkCore, mod = (not module or module == "") and "E"
showall = (showall == "true" and true) or false
delay = (delay == "nil" and nil) or tonumber(delay) or 5
minCalls = (minCalls == "nil" and nil) or tonumber(minCalls) or 15
@@ -1092,6 +1122,7 @@ function E:Initialize()
self.data.RegisterCallback(self, "OnProfileChanged", "UpdateAll")
self.data.RegisterCallback(self, "OnProfileCopied", "UpdateAll")
self.data.RegisterCallback(self, "OnProfileReset", "OnProfileReset")
self.charSettings = LibStub("AceDB-3.0"):New("ElvPrivateDB", self.privateVars)
self.private = self.charSettings.profile
self.db = self.data.profile
@@ -1105,24 +1136,27 @@ function E:Initialize()
self:LoadCommands()
self:InitializeModules()
self:LoadMovers()
self:UpdateCooldownSettings()
self:UpdateCooldownSettings("all")
self.initialized = true
if self.private.install_complete == nil then
self:Install()
end
-- if not find(date(), "04/01/") then
-- E.global.aprilFools = nil
-- end
-- if not find(date(), "04/01/") then
-- E.global.aprilFools = nil
-- end
--if self:HelloKittyFixCheck() then
-- self:HelloKittyFix()
--end
-- if self:HelloKittyFixCheck() then
-- self:HelloKittyFix()
-- end
self:UpdateMedia()
self:UpdateFrameTemplates()
--self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "CheckRole")
self:UpdateBorderColors()
self:UpdateBackdropColors()
self:UpdateStatusBars()
-- self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "CheckRole")
-- self:RegisterEvent("CHARACTER_POINTS_CHANGED", "CheckRole")
self:RegisterEvent("CVAR_UPDATE", "UIScale")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
@@ -1140,4 +1174,4 @@ function E:Initialize()
if self.db.general.loginmessage then
print(select(2, E:GetModule("Chat"):FindURL("CHAT_MSG_DUMMY", format(L["LOGIN_MSG"], self["media"].hexvaluecolor, self["media"].hexvaluecolor, self.version)))..".")
end
end
end
+276
View File
@@ -0,0 +1,276 @@
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local CP = E:NewModule("CopyProfile", "AceEvent-3.0","AceTimer-3.0","AceComm-3.0","AceSerializer-3.0")
--Cache global variables
--Lua functions
local pairs, next, type = pairs, next, type
local format, error = format, error
local getn = table.getn
--WoW API / Variables
--This table to reserve settings names in E.global.profileCopy. Used in export/imports functions
--Pligins can add own values for their internal settings for safechecks here
CP.InternalOptions = {
["selected"] = true,
["movers"] = true
}
--Default template for a config group for a single module.
--Contains header, general group toggle (shown only if the setting actually exists) and imports button.
--Usage as seen in ElvUI_Config\modulecopy.lua
function CP:CreateModuleConfigGroup(Name, section, pluginSection)
local config = {
order = 10,
type = "group",
name = Name,
args = {
header = {
order = 0,
type = "header",
name = Name
},
general = {
order = 1,
type = "toggle",
name = GENERAL
},
PreButtonSpacer = {
order = 200,
type = "description",
name = ""
},
import = {
order = 201,
type = "execute",
name = L["Import Now"],
func = function()
E.PopupDialogs["MODULE_COPY_CONFIRM"].text = format(L["You are going to copy settings for |cffD3CF00\"%s\"|r from |cff4beb2c\"%s\"|r profile to your current |cff4beb2c\"%s\"|r profile. Are you sure?"], Name, E.global.profileCopy.selected, ElvDB["profileKeys"][E.myname.." - "..E.myrealm])
E.PopupDialogs["MODULE_COPY_CONFIRM"].OnAccept = function()
CP:ImportFromProfile(section, pluginSection)
end
E:StaticPopup_Show("MODULE_COPY_CONFIRM")
end
},
export = {
order = 202,
type = "execute",
name = L["Export Now"],
func = function()
E.PopupDialogs["MODULE_COPY_CONFIRM"].text = format(L["You are going to copy settings for |cffD3CF00\"%s\"|r from your current |cff4beb2c\"%s\"|r profile to |cff4beb2c\"%s\"|r profile. Are you sure?"], Name, ElvDB["profileKeys"][E.myname.." - "..E.myrealm], E.global.profileCopy.selected)
E.PopupDialogs["MODULE_COPY_CONFIRM"].OnAccept = function()
CP:ExportToProfile(section, pluginSection)
end
E:StaticPopup_Show("MODULE_COPY_CONFIRM")
end
}
}
}
if pluginSection then
config.args.general.hidden = function(info) return E.global.profileCopy[pluginSection][section][ info[getn(info)] ] == nil end
config.args.general.get = function(info) return E.global.profileCopy[pluginSection][section][ info[getn(info)] ] end
config.args.general.set = function(info, value) E.global.profileCopy[pluginSection][section][ info[getn(info)] ] = value end
else
config.args.general.hidden = function(info) return E.global.profileCopy[section][ info[getn(info)] ] == nil end
config.args.general.get = function(info) return E.global.profileCopy[section][ info[getn(info)] ] end
config.args.general.set = function(info, value) E.global.profileCopy[section][ info[getn(info)] ] = value end
end
return config
end
function CP:CreateMoversConfigGroup()
local config = {
header = {
order = 0,
type = "header",
name = L["On screen positions for different elements."],
},
PreButtonSpacer = {
order = 200,
type = "description",
name = "",
},
import = {
order = 201,
type = "execute",
name = L["Import Now"],
func = function()
E.PopupDialogs["MODULE_COPY_CONFIRM"].text = format(L["You are going to copy settings for |cffD3CF00\"%s\"|r from |cff4beb2c\"%s\"|r profile to your current |cff4beb2c\"%s\"|r profile. Are you sure?"], L["Movers"], E.global.profileCopy.selected, ElvDB["profileKeys"][E.myname.." - "..E.myrealm])
E.PopupDialogs["MODULE_COPY_CONFIRM"].OnAccept = function()
CP:CopyMovers("import")
end
E:StaticPopup_Show("MODULE_COPY_CONFIRM")
end
},
export = {
order = 202,
type = "execute",
name = L["Export Now"],
func = function()
E.PopupDialogs["MODULE_COPY_CONFIRM"].text = format(L["You are going to copy settings for |cffD3CF00\"%s\"|r from your current |cff4beb2c\"%s\"|r profile to |cff4beb2c\"%s\"|r profile. Are you sure?"], L["Movers"], ElvDB["profileKeys"][E.myname.." - "..E.myrealm], E.global.profileCopy.selected)
E.PopupDialogs["MODULE_COPY_CONFIRM"].OnAccept = function()
CP:CopyMovers("export")
end
E:StaticPopup_Show("MODULE_COPY_CONFIRM")
end
}
}
for moverName, data in pairs(E.CreatedMovers) do
if not G.profileCopy.movers[moverName] then G.profileCopy.movers[moverName] = false end
config[moverName] = {
order = 1,
type = "toggle",
name = data.text,
get = function(info) return E.global.profileCopy.movers[moverName] end,
set = function(info, value) E.global.profileCopy.movers[moverName] = value end
}
end
for moverName, data in pairs(E.DisabledMovers) do
if not G.profileCopy.movers[moverName] then G.profileCopy.movers[moverName] = false end
config[moverName] = {
order = 1,
type = "toggle",
name = data.text,
get = function(info) return E.global.profileCopy.movers[moverName] end,
set = function(info, value) E.global.profileCopy.movers[moverName] = value end
}
end
return config
end
function CP:CopyTable(CopyFrom, CopyTo, CopyDefault, module)
for key, value in pairs(CopyTo) do
if type(value) ~= "table" then
if module == true or (type(module) == "table" and module.general == nil or (not CopyTo.general and module.general)) then --Some dark magic of a logic to figure out stuff
--This check is to see if the profile we are copying from has keys absent from defaults.
--If key exists, then copy. If not, then clear obsolite key from the profile.
if CopyDefault[key] ~= nil then
CopyTo[key] = CopyFrom[key] or CopyDefault[key]
else
CopyFrom[key] = nil
end
end
else
if module == true then --Copy over entire section of profile subgroup
E:CopyTable(CopyTo, CopyDefault)
E:CopyTable(CopyTo, CopyFrom)
elseif module[key] ~= nil then
--Making sure tables actually exist in profiles (e.g absent values in ElvDB["profiles"] are for default values)
CopyFrom[key], CopyTo[key] = CP:TablesExist(CopyFrom[key], CopyTo[key], CopyDefault[key])
--If key exists, then copy. If not, then clear obsolite key from the profile.
--Someone should double check this logic. Cause for single keys it is fine, but I'm no sure bout whole tables @Darth
if CopyFrom[key] ~= nil then
CP:CopyTable(CopyFrom[key], CopyTo[key], CopyDefault[key], module[key])
else
CopyTo[key] = nil
end
end
end
end
end
--[[
* Valid copy templates should be as follows
G["profileCopy"][YourOptionGroupName] = {
[SubGroupName1] = true,
[SubGroupName2] = true,
...
}
* For example
G["profileCopy"]["auras"] = {
["general"] = true,
["buffs"] = true,
["debuffs"] = true,
["cooldown"] = true,
}
* "general" key can refer to a similar named subtable or all non-table variables inside your group
* If you leave the table as G["profileCopy"][YourOptionGroupName] = {}, this will result in no valid copy template error.
* If set to G["profileCopy"][YourOptionGroupName] = true, then this will copy everything without selecting
any particular subcategory from your settings table.
* Plugins can use "pluginSection" argument to determain their own table if they keep settings apart from core ElvUI settings.
Examples S&L uses "sle" table, MerathilisUI uses "mui" table, BenikUI uses "benikui" and core table
]]
function CP:TablesExist(CopyFrom, CopyTo, CopyDefault)
if not CopyFrom then CopyFrom = CopyDefault end
if not CopyTo then CopyTo = CopyDefault end
return CopyFrom, CopyTo
end
function CP:ImportFromProfile(section, pluginSection)
--Some checks for the occasion someone passes wrong stuff
if not section then error("No profile section provided. Usage CP:ImportFromProfile(\"section\")") end
if not pluginSection and CP.InternalOptions[section] then error(format("Section name could not be \"%s\". This name is reserved for internal setting"), section) end
if pluginSection and CP.InternalOptions[pluginSection][section] then error(format("Section name for plugin group \"%s\" could not be \"%s\". This name is reserved for internal setting"), pluginSection, section) end
local module = pluginSection and E.global.profileCopy[pluginSection][section] or E.global.profileCopy[section]
if not module then error(format("Provided section name \"%s\" does not have a template for profile copy.", section)) end
--Starting digging through the settings
local CopyFrom = pluginSection and ElvDB["profiles"][E.global.profileCopy.selected][pluginSection][section] or ElvDB["profiles"][E.global.profileCopy.selected][section]
local CopyTo = pluginSection and E.db[pluginSection][section] or E.db[section]
local CopyDefault = pluginSection and P[pluginSection][section] or P[section]
--Making sure tables actually exist in profiles (e.g absent values in ElvDB["profiles"] are for default values)
CopyFrom, CopyTo = CP:TablesExist(CopyFrom, CopyTo, CopyDefault)
if type(module) == "table" and next(module) then --This module is not an empty table
CP:CopyTable(CopyFrom, CopyTo, CopyDefault, module)
elseif type(module) == "boolean" then --Copy over entire section of profile subgroup
E:CopyTable(CopyTo, CopyDefault)
E:CopyTable(CopyTo, CopyFrom)
else
error(format("Provided section name \"%s\" does not have a valid copy template.", section))
end
E:UpdateAll(true)
end
function CP:ExportToProfile(section, pluginSection)
--Some checks for the occasion someone passes wrong stuff
if not section then error("No profile section provided. Usage CP:ExportToProfile(\"section\")") end
if not pluginSection and CP.InternalOptions[section] then error(format("Section name could not be \"%s\". This name is reserved for internal setting"), section) end
if pluginSection and CP.InternalOptions[pluginSection][section] then error(format("Section name for plugin group \"%s\" could not be \"%s\". This name is reserved for internal setting"), pluginSection, section) end
local module = pluginSection and E.global.profileCopy[pluginSection][section] or E.global.profileCopy[section]
if not module then error(format("Provided section name \"%s\" does not have a template for profile copy.", section)) end
--Making sure tables actually exist
if not ElvDB["profiles"][E.global.profileCopy.selected][section] then ElvDB["profiles"][E.global.profileCopy.selected][section] = {} end
if not E.db[section] then E.db[section] = {} end
--Starting digging through the settings
local CopyFrom = pluginSection and E.db[pluginSection][section] or E.db[section]
local CopyTo = pluginSection and ElvDB["profiles"][E.global.profileCopy.selected][pluginSection][section] or ElvDB["profiles"][E.global.profileCopy.selected][section]
local CopyDefault = pluginSection and P[pluginSection][section] or P[section]
if type(module) == "table" and next(module) then --This module is not an empty table
CP:CopyTable(CopyFrom, CopyTo, CopyDefault, module)
elseif type(module) == "boolean" then --Copy over entire section of profile subgroup
E:CopyTable(CopyTo, CopyDefault)
E:CopyTable(CopyTo, CopyFrom)
else
error(format("Provided section name \"%s\" does not have a valid copy template.", section))
end
end
function CP:CopyMovers(mode)
if not E.db.movers then E.db.movers = {} end --Nothing was moved in cutrrent profile
if not ElvDB["profiles"][E.global.profileCopy.selected].movers then ElvDB["profiles"][E.global.profileCopy.selected].movers = {} end --Nothing was moved in selected profile
local CopyFrom, CopyTo
if mode == "export" then
CopyFrom, CopyTo = E.db.movers, ElvDB["profiles"][E.global.profileCopy.selected].movers
else
CopyFrom, CopyTo = ElvDB["profiles"][E.global.profileCopy.selected].movers or {}, E.db.movers
end
for moverName in pairs(E.CreatedMovers) do
if E.global.profileCopy.movers[moverName] then
CopyTo[moverName] = CopyFrom[moverName]
end
end
E:SetMoversPositions()
end
--Maybe actually not needed at all
function CP:Initialize()
end
local function InitializeCallback()
CP:Initialize()
end
E:RegisterModule(CP:GetName(), InitializeCallback)
+90 -28
View File
@@ -4,11 +4,10 @@ local LSM = LibStub("LibSharedMedia-3.0");
--Cache global variables
--Lua functions
local _G = _G
local unpack, type = unpack, type
local unpack, type, select, getmetatable = unpack, type, select, getmetatable
--WoW API / Variables
local CreateFrame = CreateFrame
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
--Preload shit..
E.mult = 1
@@ -17,7 +16,7 @@ local backdropr, backdropg, backdropb, backdropa, borderr, borderg, borderb = 0,
local function GetTemplate(t, isUnitFrameElement)
backdropa = 1
if t == "ClassColor" then
if(CUSTOM_CLASS_COLORS) then
if CUSTOM_CLASS_COLORS then
borderr, borderg, borderb = CUSTOM_CLASS_COLORS[E.myclass].r, CUSTOM_CLASS_COLORS[E.myclass].g, CUSTOM_CLASS_COLORS[E.myclass].b
else
borderr, borderg, borderb = RAID_CLASS_COLORS[E.myclass].r, RAID_CLASS_COLORS[E.myclass].g, RAID_CLASS_COLORS[E.myclass].b
@@ -30,14 +29,14 @@ local function GetTemplate(t, isUnitFrameElement)
end
elseif t == "Transparent" then
if isUnitFrameElement then
borderr, borderg, borderb = unpack(E["media"].bordercolor)
borderr, borderg, borderb = unpack(E["media"].unitframeBorderColor)
else
borderr, borderg, borderb = unpack(E["media"].bordercolor)
end
backdropr, backdropg, backdropb, backdropa = unpack(E["media"].backdropfadecolor)
else
if isUnitFrameElement then
borderr, borderg, borderb = unpack(E["media"].bordercolor)
borderr, borderg, borderb = unpack(E["media"].unitframeBorderColor)
else
borderr, borderg, borderb = unpack(E["media"].bordercolor)
end
@@ -52,6 +51,7 @@ function E:Size(frame, width, height)
end
function E:Width(frame, width)
assert(width)
frame:SetWidth(E:Scale(width))
end
@@ -61,7 +61,7 @@ function E:Height(frame, height)
end
function E:Point(obj, arg1, arg2, arg3, arg4, arg5)
if(arg2 == nil) then
if arg2 == nil then
arg2 = obj:GetParent()
end
@@ -105,33 +105,33 @@ end
function E:SetTemplate(f, t, glossTex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
GetTemplate(t, isUnitFrameElement)
if(t) then
if t then
f.template = t
end
if(glossTex) then
if glossTex then
f.glossTex = glossTex
end
if(ignoreUpdates) then
if ignoreUpdates then
f.ignoreUpdates = ignoreUpdates
end
if(forcePixelMode) then
if forcePixelMode then
f.forcePixelMode = forcePixelMode
end
local bgFile = E.media.blankTex
if(glossTex) then
if glossTex then
bgFile = E.media.glossTex
end
if(isUnitFrameElement) then
if isUnitFrameElement then
f.isUnitFrameElement = isUnitFrameElement
end
if(t ~= "NoBackdrop") then
if(E.private.general.pixelPerfect or f.forcePixelMode) then
if t ~= "NoBackdrop" then
if E.private.general.pixelPerfect or f.forcePixelMode then
f:SetBackdrop({
bgFile = bgFile,
edgeFile = E["media"].blankTex,
@@ -177,7 +177,7 @@ function E:SetTemplate(f, t, glossTex, ignoreUpdates, forcePixelMode, isUnitFram
f:SetBackdropColor(backdropr, backdropg, backdropb, backdropa)
f:SetBackdropBorderColor(borderr, borderg, borderb)
if(not f.ignoreUpdates) then
if not f.ignoreUpdates then
if f.isUnitFrameElement then
E["unitFrameElements"][f] = true
else
@@ -187,19 +187,20 @@ function E:SetTemplate(f, t, glossTex, ignoreUpdates, forcePixelMode, isUnitFram
end
function E:CreateBackdrop(f, t, tex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
if not f then return end
if(not t) then t = "Default" end
if not t then t = "Default" end
local b = CreateFrame("Frame", nil, f)
if(f.forcePixelMode or forcePixelMode) then
local parent = f.IsObjectType and f:IsObjectType("Texture") and f:GetParent() or f
local b = CreateFrame("Frame", nil, parent)
if f.forcePixelMode or forcePixelMode then
E:SetOutside(b, nil, E.mult, E.mult)
else
E:SetOutside(b)
end
E:SetTemplate(b, t, tex, ignoreUpdates, forcePixelMode, isUnitFrameElement)
if(f:GetFrameLevel() - 1 >= 0) then
b:SetFrameLevel(f:GetFrameLevel() - 1)
if (parent:GetFrameLevel() - 1) >= 0 then
b:SetFrameLevel(parent:GetFrameLevel() - 1)
else
b:SetFrameLevel(0)
end
@@ -217,10 +218,7 @@ function E:CreateShadow(f)
shadow:SetFrameLevel(1)
shadow:SetFrameStrata(f:GetFrameStrata())
E:SetOutside(shadow, f, 3, 3)
shadow:SetBackdrop({
edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(3),
insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}
})
shadow:SetBackdrop({edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(3)})
shadow:SetBackdropColor(backdropr, backdropg, backdropb, 0)
shadow:SetBackdropBorderColor(borderr, borderg, borderb, 0.9)
f.shadow = shadow
@@ -238,7 +236,8 @@ function E:Kill(object)
end
function E:StripTextures(object, kill)
for _, region in ipairs({object:GetRegions()}) do
for i = 1, object:GetNumRegions() do
local region = select(i, object:GetRegions())
if region and region:GetObjectType() == "Texture" then
if kill and type(kill) == "boolean" then
E:Kill(region)
@@ -262,7 +261,7 @@ function E:FontTemplate(fs, font, fontSize, fontStyle)
fontSize = fontSize or E.db.general.fontSize
if fontStyle == "OUTLINE" and (E.db.general.font == "Homespun") then
if (fontSize > 10 and not fs.fontSize) then
if fontSize > 10 and not fs.fontSize then
fontStyle = "MONOCHROMEOUTLINE"
fontSize = 10
end
@@ -310,4 +309,67 @@ function E:StyleButton(button, noHover, noPushed, noChecked)
cooldown:ClearAllPoints()
E:SetInside(cooldown)
end
end
end
function E:CreateCloseButton(frame, size, offset, texture, backdrop)
size = (size or 16)
offset = (offset or -6)
texture = (texture or "Interface\\AddOns\\ElvUI\\media\\textures\\close.tga")
local CloseButton = CreateFrame("Button", nil, frame)
E:Size(CloseButton, size)
E:Point(CloseButton, "TOPRIGHT", offset, offset)
if backdrop then
E:CreateBackdrop(CloseButton, "Default", true)
end
CloseButton.Texture = CloseButton:CreateTexture(nil, "OVERLAY")
CloseButton.Texture:SetAllPoints()
CloseButton.Texture:SetTexture(texture)
CloseButton:SetScript("OnClick", function()
this:GetParent():Hide()
end)
CloseButton:SetScript("OnEnter", function()
this.Texture:SetVertexColor(unpack(E["media"].rgbvaluecolor))
end)
CloseButton:SetScript("OnLeave", function()
this.Texture:SetVertexColor(1, 1, 1)
end)
frame.CloseButton = CloseButton
end
--[[local function addapi(object)
local mt = getmetatable(object).__index
if not object.Size then mt.Size = Size end
if not object.Point then mt.Point = Point end
if not object.SetOutside then mt.SetOutside = SetOutside end
if not object.SetInside then mt.SetInside = SetInside end
if not object.SetTemplate then mt.SetTemplate = SetTemplate end
if not object.CreateBackdrop then mt.CreateBackdrop = CreateBackdrop end
if not object.CreateShadow then mt.CreateShadow = CreateShadow end
if not object.Kill then mt.Kill = Kill end
if not object.Width then mt.Width = Width end
if not object.Height then mt.Height = Height end
if not object.FontTemplate then mt.FontTemplate = FontTemplate end
if not object.StripTextures then mt.StripTextures = StripTextures end
if not object.StyleButton then mt.StyleButton = StyleButton end
if not object.CreateCloseButton then mt.CreateCloseButton = CreateCloseButton end
end
local handled = {["Frame"] = true}
local object = CreateFrame("Frame")
addapi(object)
addapi(object:CreateTexture())
addapi(object:CreateFontString())
object = EnumerateFrames()
while object do
if not handled[object:GetObjectType()] then
addapi(object)
handled[object:GetObjectType()] = true
end
object = EnumerateFrames(object)
end--]]