Verified Commit bed1910c authored by NihilisticPandemonium's avatar NihilisticPandemonium

11.21

parents 6513a1dc 616085f5
--[[
* Collection of functions that can be used in multiple places
]]
------------------------------------------------------------------------
-- Collection of functions that can be used in multiple places
------------------------------------------------------------------------
local E, L, V, P, G = unpack(select(2, ...))
local _G = _G
local twipe = twipe
local format, select, type, pairs, date = format, select, type, pairs, date
local wipe, date = wipe, date
local format, select, type, ipairs, pairs = format, select, type, ipairs, pairs
local strmatch, strfind, tonumber, tostring = strmatch, strfind, tonumber, tostring
local CreateFrame = CreateFrame
local GetAddOnEnableState = GetAddOnEnableState
local GetBattlefieldArenaFaction = GetBattlefieldArenaFaction
local GetCVar, SetCVar = GetCVar, SetCVar
local GetCVarBool = GetCVarBool
local GetFunctionCPUUsage = GetFunctionCPUUsage
local GetInstanceInfo = GetInstanceInfo
local GetSpecialization = GetSpecialization
local GetSpecializationRole = GetSpecializationRole
local InCombatLockdown = InCombatLockdown
local IsAddOnLoaded = IsAddOnLoaded
local IsInInstance = IsInInstance
local IsRatedBattleground = IsRatedBattleground
local IsWargame = IsWargame
local PLAYER_FACTION_GROUP = PLAYER_FACTION_GROUP
local RequestBattlefieldScoreData = RequestBattlefieldScoreData
local UIParentLoadAddOn = UIParentLoadAddOn
local UnitAttackPower = UnitAttackPower
local UnitFactionGroup = UnitFactionGroup
local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitHasVehicleUI = UnitHasVehicleUI
local UnitStat = UnitStat
local IsRatedBattleground = IsRatedBattleground
local IsWargame = IsWargame
local GetBattlefieldArenaFaction = GetBattlefieldArenaFaction
local UnitIsMercenary = UnitIsMercenary
local PLAYER_FACTION_GROUP = PLAYER_FACTION_GROUP
local UnitStat = UnitStat
local C_PetBattles_IsInBattle = C_PetBattles.IsInBattle
local C_UIWidgetManager_GetStatusBarWidgetVisualizationInfo = C_UIWidgetManager.GetStatusBarWidgetVisualizationInfo
local FACTION_HORDE = FACTION_HORDE
local FACTION_ALLIANCE = FACTION_ALLIANCE
function E:IsFoolsDay()
return strfind(date(), '04/01/') and not E.global.aprilFools
end
do -- other non-english locales require this
E.UnlocalizedClasses = {}
for k,v in pairs(_G.LOCALIZED_CLASS_NAMES_MALE) do E.UnlocalizedClasses[v] = k end
......@@ -48,6 +44,40 @@ do -- other non-english locales require this
end
end
function E:IsFoolsDay()
return strfind(date(), '04/01/') and not E.global.aprilFools
end
function E:ScanTooltipTextures(clean, grabTextures)
local essenceTextureID, textures, essences = 2975691
for i = 1, 10 do
local tex = _G["ElvUI_ScanTooltipTexture"..i]
local texture = tex and tex:GetTexture()
if texture then
if grabTextures then
if not textures then textures = {} end
if texture == essenceTextureID then
if not essences then essences = {} end
local selected = (textures[i-1] ~= essenceTextureID and textures[i-1]) or nil
essences[i] = {selected, tex:GetAtlas(), texture}
if selected then
textures[i-1] = nil
end
else
textures[i] = texture
end
end
if clean then
tex:SetTexture()
end
end
end
return textures, essences
end
function E:GetPlayerRole()
local assignedRole = UnitGroupRolesAssigned('player')
if assignedRole == 'NONE' then
......@@ -212,7 +242,7 @@ do
E:Print('CPU Usage: No CPU Usage differences found.')
end
twipe(CPU_USAGE)
wipe(CPU_USAGE)
end
function E:GetTopCPUFunc(msg)
......@@ -228,7 +258,7 @@ do
delay = (delay == 'nil' and nil) or tonumber(delay) or 5
minCalls = (minCalls == 'nil' and nil) or tonumber(minCalls) or 15
twipe(CPU_USAGE)
wipe(CPU_USAGE)
if module == 'all' then
for moduName, modu in pairs(self.modules) do
for funcName, func in pairs(modu) do
......@@ -419,7 +449,6 @@ function E:RequestBGInfo()
end
function E:PLAYER_ENTERING_WORLD()
self:MapInfo_Update()
self:CheckRole()
if not self.MediaUpdated then
......@@ -427,7 +456,7 @@ function E:PLAYER_ENTERING_WORLD()
self.MediaUpdated = true
end
local _, instanceType = IsInInstance()
local _, instanceType = GetInstanceInfo()
if instanceType == 'pvp' then
self.BGTimer = self:ScheduleRepeatingTimer('RequestBGInfo', 5)
self:RequestBGInfo()
......
......@@ -5,7 +5,6 @@ local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, Private
--Lua functions
local random, next, unpack, strsub = random, next, unpack, strsub
--WoW API / Variables
E.AnimShake = {{-9,7,-7,12}, {-5,9,-9,5}, {-5,7,-7,5}, {-9,9,-9,9}, {-5,7,-7,5}, {-9,7,-9,5}}
E.AnimShakeH = {-5,5,-2,5,-2,5}
......
--[[
Collection of previous april fools pranks
Harlem Shake: Try it out with the command /harlemshake
Hello Kitty: Try it out with the command /hellokitty (pay attention to the popups, read what it says)
]]
------------------------------------------------------------------------
-- Collection of previous april fools pranks
-- Harlem Shake: Try it out with the command /harlemshake
-- Hello Kitty: Try it out with the command /hellokitty (pay attention to the popups, read what it says)
------------------------------------------------------------------------
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local UF = E:GetModule('UnitFrames')
local AB = E:GetModule('ActionBars')
......@@ -42,7 +40,7 @@ do
E:CancelTimer(E.massiveShakeTimer)
end
E.global.aprilFools = true;
E.global.aprilFools = true
E:StaticPopup_Hide("HARLEM_SHAKE")
twipe(self.massiveShakeObjects)
DoEmote("Dance")
......@@ -109,7 +107,7 @@ do
end
function E:HarlemShakeToggle()
self:StaticPopup_Show("HARLEM_SHAKE");
self:StaticPopup_Show("HARLEM_SHAKE")
end
end
......
......@@ -181,20 +181,20 @@ end
local function ConfigMode_OnClick(self)
selectedValue = self.value
E:ToggleMoveMode(false, self.value)
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, self.value);
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, self.value)
end
local function ConfigMode_Initialize()
local info = _G.UIDropDownMenu_CreateInfo();
info.func = ConfigMode_OnClick;
local info = _G.UIDropDownMenu_CreateInfo()
info.func = ConfigMode_OnClick
for _, configMode in ipairs(E.ConfigModeLayouts) do
info.text = E.ConfigModeLocalizedStrings[configMode];
info.value = configMode;
_G.UIDropDownMenu_AddButton(info);
info.text = E.ConfigModeLocalizedStrings[configMode]
info.value = configMode
_G.UIDropDownMenu_AddButton(info)
end
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue);
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
end
function E:NudgeMover(nudgeX, nudgeY)
......@@ -226,7 +226,7 @@ function E:UpdateNudgeFrame(mover, x, y)
end
function E:AssignFrameToNudge()
ElvUIMoverNudgeWindow.child = self;
ElvUIMoverNudgeWindow.child = self
E:UpdateNudgeFrame(self)
end
......@@ -244,7 +244,7 @@ function E:CreateMoverPopup()
f:Point("BOTTOM", _G.UIParent, 'CENTER', 0, 100)
f:SetScript('OnHide', function()
if ElvUIMoverPopupWindowDropDown then
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, 'ALL');
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, 'ALL')
end
end)
f:SetBackdropBorderColor(unpack(E.media.rgbvaluecolor))
......@@ -297,7 +297,7 @@ function E:CreateMoverPopup()
end
selectedValue = 'ALL'
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue);
_G.UIDropDownMenu_SetSelectedValue(ElvUIMoverPopupWindowDropDown, selectedValue)
end)
local align = CreateFrame('EditBox', f:GetName()..'EditBox', f, 'InputBoxTemplate')
......@@ -360,7 +360,7 @@ function E:CreateMoverPopup()
configMode.text:Point('RIGHT', configMode.backdrop, 'LEFT', -2, 0)
configMode.text:SetText(L["Config Mode:"])
_G.UIDropDownMenu_Initialize(configMode, ConfigMode_Initialize);
_G.UIDropDownMenu_Initialize(configMode, ConfigMode_Initialize)
local nudgeFrame = CreateFrame('Frame', 'ElvUIMoverNudgeWindow', E.UIParent)
nudgeFrame:SetFrameStrata("DIALOG")
......
......@@ -31,9 +31,9 @@ local LSM = E.Libs.LSM
--Lua functions
local _G = _G
local tonumber, pairs, ipairs, error, unpack, select, tostring = tonumber, pairs, ipairs, error, unpack, select, tostring
local assert, type, xpcall, next, print = assert, type, xpcall, next, print
local gsub, strjoin, twipe, tinsert, tremove = gsub, strjoin, wipe, tinsert, tremove
local gsub, strjoin, twipe, tinsert, tremove, tContains = gsub, strjoin, wipe, tinsert, tremove, tContains
local format, find, strrep, strlen, sub = format, strfind, strrep, strlen, strsub
local assert, type, pcall, xpcall, next, print = assert, type, pcall, xpcall, next, print
--WoW API / Variables
local CreateFrame = CreateFrame
local GetCVar = GetCVar
......@@ -54,7 +54,6 @@ local ERR_NOT_IN_COMBAT = ERR_NOT_IN_COMBAT
local LE_PARTY_CATEGORY_HOME = LE_PARTY_CATEGORY_HOME
local LE_PARTY_CATEGORY_INSTANCE = LE_PARTY_CATEGORY_INSTANCE
local C_ChatInfo_SendAddonMessage = C_ChatInfo.SendAddonMessage
local C_Timer_After = C_Timer.After
-- GLOBALS: ElvUIPlayerBuffs, ElvUIPlayerDebuffs
--Constants
......@@ -666,7 +665,8 @@ do --The code in this function is from WeakAuras, credit goes to Mirrored and th
return str
end
local function recurse(tbl, ret, profileText, sameLine)
local sameLine
local function recurse(tbl, ret, profileText)
local lineStructure = buildLineStructure(profileText)
for k, v in pairs(tbl) do
if not sameLine then
......@@ -685,7 +685,7 @@ do --The code in this function is from WeakAuras, credit goes to Mirrored and th
tinsert(lineStructureTable, k)
sameLine = true
ret = ret..']'
ret = recurse(v, ret, profileText, sameLine)
ret = recurse(v, ret, profileText)
else
sameLine = false
ret = ret..'] = '
......@@ -718,7 +718,8 @@ do --The code in this function is from WeakAuras, credit goes to Mirrored and th
twipe(lineStructureTable)
local ret = ""
if inTable and profileType then
ret = recurse(inTable, ret, profileText, false)
sameLine = false
ret = recurse(inTable, ret, profileText)
end
return ret
......@@ -1029,17 +1030,14 @@ do
nextDelay = 0.05
end
C_Timer_After(nextDelay or staggerDelay, E[nextUpdate])
E:Delay(nextDelay or staggerDelay, E[nextUpdate])
end
end
E:RegisterCallback("StaggeredUpdate", CallStaggeredUpdate)
function E:StaggeredUpdateAll(event, installSetup)
if not self.initialized then
C_Timer_After(1, function()
E:StaggeredUpdateAll(event, installSetup)
end)
E:Delay(1, E.StaggeredUpdateAll, E, event, installSetup)
return
end
......@@ -1099,19 +1097,42 @@ function E:UpdateAll(doUpdates)
end
do
local EventRegister = {}
local EventFrame = CreateFrame('Frame')
EventFrame:SetScript('OnEvent', function(_, event, ...)
if EventRegister[event] then
for object, functions in pairs(EventRegister[event]) do
for _, func in ipairs(functions) do
--Call the functions that are registered with this object, and pass the object and other arguments back
E.ObjectEventTable, E.ObjectEventFrame = {}, CreateFrame('Frame')
local eventFrame, eventTable = E.ObjectEventFrame, E.ObjectEventTable
eventFrame:SetScript('OnEvent', function(_, event, ...)
local objs = eventTable[event]
if objs then
for object, funcs in pairs(objs) do
for _, func in ipairs(funcs) do
func(object, event, ...)
end
end
end
end)
function E:HasFunctionForObject(event, object, func)
if not (event and object and func) then
E:Print('Error. Usage: HasFunctionForObject(event, object, func)')
return
end
local objs = eventTable[event]
local funcs = objs and objs[object]
return funcs and tContains(funcs, func)
end
function E:IsEventRegisteredForObject(event, object)
if not (event and object) then
E:Print('Error. Usage: IsEventRegisteredForObject(event, object)')
return
end
local objs = eventTable[event]
local funcs = objs and objs[object]
return funcs ~= nil, funcs
end
--- Registers specified event and adds specified func to be called for the specified object.
-- Unless all parameters are supplied it will not register.
-- If the specified object has already been registered for the specified event
......@@ -1122,20 +1143,23 @@ do
-- @param object The object you want to register the event for.
-- @param func The function you want executed for this object.
function E:RegisterEventForObject(event, object, func)
if not event or not object or not func then
if not (event and object and func) then
E:Print('Error. Usage: RegisterEventForObject(event, object, func)')
return
end
if not EventRegister[event] then --Check if event has already been registered
EventRegister[event] = {}
EventFrame:RegisterEvent(event)
else
if not EventRegister[event][object] then --Check if this object has already been registered
EventRegister[event][object] = {func}
else
tinsert(EventRegister[event][object], func) --Add func that should be called for this object on this event
end
local objs = eventTable[event]
if not objs then
objs = {}
eventTable[event] = objs
pcall(eventFrame.RegisterEvent, eventFrame, event)
end
local funcs = objs[object]
if not funcs then
objs[object] = {func}
elseif not tContains(funcs, func) then
tinsert(funcs, func)
end
end
......@@ -1145,29 +1169,28 @@ do
-- @param object The object you want to unregister a func from.
-- @param func The function you want unregistered for the object.
function E:UnregisterEventForObject(event, object, func)
if not event or not object or not func then
if not (event and object and func) then
E:Print('Error. Usage: UnregisterEventForObject(event, object, func)')
return
end
--Find the specified function for the specified object and remove it from the register
if EventRegister[event] and EventRegister[event][object] then
for index, registeredFunc in ipairs(EventRegister[event][object]) do
if func == registeredFunc then
tremove(EventRegister[event][object], index)
local objs = eventTable[event]
local funcs = objs and objs[object]
if funcs then
for index, fnc in ipairs(funcs) do
if func == fnc then
tremove(funcs, index)
break
end
end
--If this object no longer has any functions registered then remove it from the register
if #EventRegister[event][object] == 0 then
EventRegister[event][object] = nil
if #funcs == 0 then
objs[object] = nil
end
--If this event no longer has any objects registered then unregister it and remove it from the register
if not next(EventRegister[event]) then
EventFrame:UnregisterEvent(event)
EventRegister[event] = nil
if not next(funcs) then
eventFrame:UnregisterEvent(event)
eventTable[event] = nil
end
end
end
......
......@@ -78,8 +78,8 @@ function E:DropDown(list, frame, xOffset, yOffset)
frame:Height((#list * BUTTON_HEIGHT) + PADDING * 2)
frame:Width(BUTTON_WIDTH + PADDING * 2)
local UIScale = _G.UIParent:GetScale();
local x, y = GetCursorPosition();
local UIScale = _G.UIParent:GetScale()
local x, y = GetCursorPosition()
x = x/UIScale
y = y/UIScale
frame:ClearAllPoints()
......
......@@ -10,12 +10,15 @@ local CreateFrame = CreateFrame
local UnitPosition = UnitPosition
local GetUnitSpeed = GetUnitSpeed
local CreateVector2D = CreateVector2D
local GetRealZoneText = GetRealZoneText
local GetMinimapZoneText = GetMinimapZoneText
local C_Map_GetMapInfo = C_Map.GetMapInfo
local C_Map_GetBestMapForUnit = C_Map.GetBestMapForUnit
local C_Map_GetWorldPosFromMapPos = C_Map.GetWorldPosFromMapPos
local MapUtil = MapUtil
E.MapInfo = {}
function E:MapInfo_Update()
local mapID = C_Map_GetBestMapForUnit("player")
......@@ -26,6 +29,8 @@ function E:MapInfo_Update()
E.MapInfo.mapID = mapID or nil
E.MapInfo.zoneText = (mapID and E:GetZoneText(mapID)) or nil
E.MapInfo.subZoneText = GetMinimapZoneText() or nil
E.MapInfo.realZoneText = GetRealZoneText() or nil
local continent = mapID and MapUtil.GetMapParentInfo(mapID, Enum.UIMapType.Continent, true)
E.MapInfo.continentParentMapID = (continent and continent.parentMapID) or nil
......@@ -158,6 +163,7 @@ E:RegisterEvent("PLAYER_STARTED_MOVING", "MapInfo_CoordsStart")
E:RegisterEvent("PLAYER_STOPPED_MOVING", "MapInfo_CoordsStop")
E:RegisterEvent("PLAYER_CONTROL_LOST", "MapInfo_CoordsStart")
E:RegisterEvent("PLAYER_CONTROL_GAINED", "MapInfo_CoordsStop")
E:RegisterEvent("ZONE_CHANGED_NEW_AREA", "MapInfo_Update")
E:RegisterEvent("ZONE_CHANGED_INDOORS", "MapInfo_Update")
E:RegisterEvent("ZONE_CHANGED", "MapInfo_Update")
E:RegisterEventForObject("LOADING_SCREEN_DISABLED", E.MapInfo, E.MapInfo_Update)
E:RegisterEventForObject("ZONE_CHANGED_NEW_AREA", E.MapInfo, E.MapInfo_Update)
E:RegisterEventForObject("ZONE_CHANGED_INDOORS", E.MapInfo, E.MapInfo_Update)
E:RegisterEventForObject("ZONE_CHANGED", E.MapInfo, E.MapInfo_Update)
......@@ -4,7 +4,6 @@ local MC = E:GetModule('ModuleCopy')
--Lua functions
local pairs, next, type = pairs, next, type
local format, error = format, error
--WoW API / Variables
-- GLOBALS: ElvDB
--This table to reserve settings names in E.global.profileCopy. Used in export/imports functions
......@@ -168,25 +167,24 @@ function MC:CopyTable(CopyFrom, CopyTo, CopyDefault, module)
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
* 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 MC:TablesExist(CopyFrom, CopyTo, CopyDefault)
......
......@@ -17,7 +17,7 @@ E.CreatedMovers = {}
E.DisabledMovers = {}
local function SizeChanged(frame)
if InCombatLockdown() then return; end
if InCombatLockdown() then return end
if frame.dirtyWidth and frame.dirtyHeight then
frame.mover:Size(frame.dirtyWidth, frame.dirtyHeight)
......
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
--Lua functions
local _G = _G
local min, max, abs, floor = min, max, abs, floor
local format, tonumber = format, tonumber
--WoW API / Variables
local UIParent = UIParent
function E:IsEyefinity(width, height)
if E.global.general.eyefinity and width >= 3840 then
......@@ -33,7 +33,6 @@ function E:UIScale(init)
E.Spacing = (E.PixelMode and 0) or E.mult
E.Border = ((not E.twoPixelsPlease) and E.PixelMode and E.mult) or E.mult*2
else --E.Initialize
local UIParent = _G.UIParent
UIParent:SetScale(scale)
--Check if we are using `E.eyefinity`
......@@ -78,10 +77,7 @@ function E:PixelScaleChanged(event, skip)
E:UIScale(true) -- repopulate variables
E:UIScale() -- setup the scale
if E.RefreshGUI then
E.Libs.AceConfigDialog:SetDefaultSize("ElvUI", E:GetConfigSize())
E:RefreshGUI()
end
E:UpdateConfigSize(true) -- reposition config