Skip to content

Commit

Permalink
Merge branch 'main' into ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Jan 9, 2025
2 parents 2ef3de6 + 9a607f9 commit 046221d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 57 deletions.
64 changes: 44 additions & 20 deletions ElvUI/Core/General/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ local strfind, strlen, tonumber, tostring = strfind, strlen, tonumber, tostring
local CopyTable = CopyTable
local CreateFrame = CreateFrame
local GetBattlefieldArenaFaction = GetBattlefieldArenaFaction
local GetClassInfo = GetClassInfo
local GetGameTime = GetGameTime
local GetInstanceInfo = GetInstanceInfo
local GetNumGroupMembers = GetNumGroupMembers
Expand All @@ -42,6 +41,7 @@ local UnitInRaid = UnitInRaid
local UnitIsMercenary = UnitIsMercenary
local UnitIsPlayer = UnitIsPlayer
local UnitIsUnit = UnitIsUnit
local UnitSex = UnitSex

local GetWatchedFactionInfo = GetWatchedFactionInfo
local GetWatchedFactionData = C_Reputation and C_Reputation.GetWatchedFactionData
Expand All @@ -55,6 +55,7 @@ local GetSpecializationInfo = (E.Classic or E.Cata) and LCS.GetSpecializationInf

local IsAddOnLoaded = C_AddOns.IsAddOnLoaded
local StoreEnabled = C_StorePublic.IsEnabled
local GetClassInfo = C_CreatureInfo.GetClassInfo
local C_TooltipInfo_GetUnit = C_TooltipInfo and C_TooltipInfo.GetUnit
local C_TooltipInfo_GetHyperlink = C_TooltipInfo and C_TooltipInfo.GetHyperlink
local C_TooltipInfo_GetInventoryItem = C_TooltipInfo and C_TooltipInfo.GetInventoryItem
Expand Down Expand Up @@ -222,6 +223,26 @@ function E:InverseClassColor(class, usePriestColor, forceCap)
return color
end

do
local classByID = {}
local classByFile = {}

E.ClassInfoByID = classByID
E.ClassInfoByFile = classByFile

for index = 1, 15 do -- really blizzard, whats up with this on anniversary?
local info = GetClassInfo(index)
if info then
classByID[info.classID] = info
classByFile[info.classFile] = info
end
end

function E:GetClassInfo(value) -- classFile or classID
return classByFile[value] or classByID[value]
end
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
Expand All @@ -230,6 +251,15 @@ do -- other non-english locales require this
function E:UnlocalizedClassName(className)
return E.UnlocalizedClasses[className]
end

function E:LocalizedClassName(className, unit)
local gender = (not unit and E.mygender) or UnitSex(unit)
if gender == 3 then
return _G.LOCALIZED_CLASS_NAMES_FEMALE[className]
else
return _G.LOCALIZED_CLASS_NAMES_MALE[className]
end
end
end

do
Expand Down Expand Up @@ -1178,33 +1208,31 @@ function E:LoadAPI()
local MALE = _G.LOCALIZED_CLASS_NAMES_MALE
local FEMALE = _G.LOCALIZED_CLASS_NAMES_FEMALE

local i = 1
local className, classFile, classID = GetClassInfo(i)
local male, female = MALE[classFile], FEMALE[classFile]
while classID do
for index, id in next, E.SpecByClass[classFile] do
local info = {
for _, info in next, E.ClassInfoByID do
local male, female = MALE[info.classFile], FEMALE[info.classFile]
for index, id in next, E.SpecByClass[info.classFile] do
local data = {
id = id,
index = index,
classFile = classFile,
className = className,
classFile = info.classFile,
className = info.className,
englishName = E.SpecName[id]
}

E.SpecInfoBySpecID[id] = info
E.SpecInfoBySpecID[id] = data

for x = 3, 1, -1 do
local _, name, desc, icon, role = GetSpecializationInfoForSpecID(id, x)

if x == 1 then -- SpecInfoBySpecID
info.name = name
info.desc = desc
info.icon = icon
info.role = role
data.name = name
data.desc = desc
data.icon = icon
data.role = role

E.SpecInfoBySpecClass[name..' '..className] = info
E.SpecInfoBySpecClass[name..' '..info.className] = data
else
local copy = E:CopyTable({}, info)
local copy = E:CopyTable({}, data)
copy.name = name
copy.desc = desc
copy.icon = icon
Expand All @@ -1219,10 +1247,6 @@ function E:LoadAPI()
end
end
end

i = i + 1
className, classFile, classID = GetClassInfo(i)
male, female = MALE[classFile], FEMALE[classFile]
end
end

Expand Down
1 change: 1 addition & 0 deletions ElvUI/Core/General/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ E.version, E.versionString, E.versionDev, E.versionGit = E:ParseVersionString('E
E.myfaction, E.myLocalizedFaction = UnitFactionGroup('player')
E.myLocalizedClass, E.myclass, E.myClassID = UnitClass('player')
E.myLocalizedRace, E.myrace, E.myRaceID = UnitRace('player')
E.mygender = UnitSex('player')
E.mylevel = UnitLevel('player')
E.myname = UnitName('player')
E.myrealm = GetRealmName()
Expand Down
28 changes: 12 additions & 16 deletions ElvUI/Mainline/Modules/Nameplates/PVPRole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local ElvUF = E.oUF
local wipe = wipe
local format = format

local GetClassInfo = GetClassInfo
local UnitName = UnitName
local GetInstanceInfo = GetInstanceInfo
local GetBattlefieldScore = GetBattlefieldScore
local GetArenaOpponentSpec = GetArenaOpponentSpec
Expand All @@ -15,7 +15,6 @@ local GetSpecializationInfoByID = GetSpecializationInfoByID
local GetSpecializationInfoForClassID = GetSpecializationInfoForClassID
local GetNumSpecializationsForClassID = GetNumSpecializationsForClassID

local UnitName = UnitName
local UNKNOWN = UNKNOWN

local Healers, HealerSpecs = {}, {}
Expand All @@ -28,20 +27,17 @@ NP.PVPRole = {
TankSpecs = TankSpecs
}

for i = 1, _G.MAX_CLASSES do
local _, _, classID = GetClassInfo(i)
if classID then
for specIndex = 1, GetNumSpecializationsForClassID(classID) do
local _, mName, _, _, role = GetSpecializationInfoForClassID(classID, specIndex, 2)
local _, fName = GetSpecializationInfoForClassID(classID, specIndex, 3)

if role == 'HEALER' then
HealerSpecs[mName] = true
HealerSpecs[fName] = true
elseif role == 'TANK' then
TankSpecs[mName] = true
TankSpecs[fName] = true
end
for classID in next, E.ClassInfoByID do
for specIndex = 1, GetNumSpecializationsForClassID(classID) do
local _, mName, _, _, role = GetSpecializationInfoForClassID(classID, specIndex, 2)
local _, fName = GetSpecializationInfoForClassID(classID, specIndex, 3)

if role == 'HEALER' then
HealerSpecs[mName] = true
HealerSpecs[fName] = true
elseif role == 'TANK' then
TankSpecs[mName] = true
TankSpecs[fName] = true
end
end
end
Expand Down
9 changes: 3 additions & 6 deletions ElvUI_Options/Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local UnitExists = UnitExists
local UnitIsUnit = UnitIsUnit
local UnitIsFriend = UnitIsFriend
local UnitIsPlayer = UnitIsPlayer
local GetClassInfo = GetClassInfo

local CLASS_SORT_ORDER = CLASS_SORT_ORDER
local NUM_CLASSES = #CLASS_SORT_ORDER

Expand Down Expand Up @@ -68,11 +68,8 @@ C.Values = {
do
C.ClassTable = {}

for i = 1, NUM_CLASSES do
local name, tag = GetClassInfo(i)
if tag then
C.ClassTable[tag] = name
end
for _, info in next, E.ClassInfoByID do
C.ClassTable[info.classFile] = info.className
end
end

Expand Down
28 changes: 13 additions & 15 deletions ElvUI_Options/Core/StyleFilters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ local _G = _G
local wipe, pairs, strmatch, strsplit, tostring = wipe, pairs, strmatch, strsplit, tostring
local next, sort, tinsert, tonumber, format = next, sort, tinsert, tonumber, format

local GetClassInfo = GetClassInfo
local GetDifficultyInfo = GetDifficultyInfo
local GetInstanceInfo = GetInstanceInfo
local GetRealZoneText = GetRealZoneText
Expand Down Expand Up @@ -346,25 +345,24 @@ StyleFilters.triggers.args.faction.args.types.args.Neutral = ACH:Toggle(L["Neutr

StyleFilters.triggers.args.class = ACH:Group(L["CLASS"], nil, 12, nil, nil, nil, DisabledFilter)

for index = 1, C.Values.NUM_CLASSES do
local className, classTag, classID = GetClassInfo(index)
if classTag then
local coloredName = E:ClassColor(classTag)
coloredName = (coloredName and coloredName.colorStr) or 'ff666666'
StyleFilters.triggers.args.class.args[classTag] = ACH:Toggle(format('|c%s%s|r', coloredName, className), nil, tIndexOf(sortedClasses, classTag), nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classTag] return tagTrigger and tagTrigger.enabled end, function(_, value) local triggers = GetFilter(true) local tagTrigger = triggers.class[classTag] if not tagTrigger then triggers.class[classTag] = {} end if value then triggers.class[classTag].enabled = value else triggers.class[classTag] = nil end NP:ConfigureAll() end)
for classID, info in next, E.ClassInfoByID do
local className, classFile = info.className, info.classFile

local group = ACH:Group(className, nil, tIndexOf(sortedClasses, classTag) + 13, nil, nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classTag] return not tagTrigger or not tagTrigger.enabled end)
group.inline = true
local coloredName = E:ClassColor(classFile)
coloredName = (coloredName and coloredName.colorStr) or 'ff666666'
StyleFilters.triggers.args.class.args[classFile] = ACH:Toggle(format('|c%s%s|r', coloredName, className), nil, tIndexOf(sortedClasses, classFile), nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classFile] return tagTrigger and tagTrigger.enabled end, function(_, value) local triggers = GetFilter(true) local tagTrigger = triggers.class[classFile] if not tagTrigger then triggers.class[classFile] = {} end if value then triggers.class[classFile].enabled = value else triggers.class[classFile] = nil end NP:ConfigureAll() end)

for k = 1, GetNumSpecializationsForClassID(classID) do
local specID, name = GetSpecializationInfoForClassID(classID, k)
local group = ACH:Group(className, nil, tIndexOf(sortedClasses, classFile) + 13, nil, nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classFile] return not tagTrigger or not tagTrigger.enabled end)
group.inline = true

local tagID = format('%s%s', classTag, specID)
group.args[tagID] = ACH:Toggle(format('|c%s%s|r', coloredName, name), nil, k, nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classTag] return tagTrigger and tagTrigger.specs and tagTrigger.specs[specID] end, function(_, value) local triggers = GetFilter(true) local tagTrigger = triggers.class[classTag] if not tagTrigger.specs then triggers.class[classTag].specs = {} end triggers.class[classTag].specs[specID] = value or nil if not next(triggers.class[classTag].specs) then triggers.class[classTag].specs = nil end NP:ConfigureAll() end)
end
for k = 1, GetNumSpecializationsForClassID(classID) do
local specID, name = GetSpecializationInfoForClassID(classID, k)

StyleFilters.triggers.args.class.args[format('%s%s', classTag, 'spec')] = group
local tagID = format('%s%s', classFile, specID)
group.args[tagID] = ACH:Toggle(format('|c%s%s|r', coloredName, name), nil, k, nil, nil, nil, function() local triggers = GetFilter(true) local tagTrigger = triggers.class[classFile] return tagTrigger and tagTrigger.specs and tagTrigger.specs[specID] end, function(_, value) local triggers = GetFilter(true) local tagTrigger = triggers.class[classFile] if not tagTrigger.specs then triggers.class[classFile].specs = {} end triggers.class[classFile].specs[specID] = value or nil if not next(triggers.class[classFile].specs) then triggers.class[classFile].specs = nil end NP:ConfigureAll() end)
end

StyleFilters.triggers.args.class.args[format('%s%s', classFile, 'spec')] = group
end

local EquippedValues = {
Expand Down

0 comments on commit 046221d

Please sign in to comment.